views:

2048

answers:

2

Hi everyone,

I'm trying to set the main class in netbeans to be the main class it was in the last environment it was in, however the program insists it can't find the main class itself and when I set it as the name of the main class in project properties it says the class does not exist (even though it does).

When I right click on the source file with the main class and hit 'run [file]' it works (albeit with errors related to assets which I can fix later on, has nothing to do with the code itself.

All I did as of now is simply copy and paste the code into netbeans from the last project, so would I be overlooking anything here?

Thanks for any help.

A: 

Do you really speak about an applet? Applets have no main-class (they can, but they do not have to). So you probably have an option to import the project as an applet-project, not as standalone-java-app, in Netbeans.

Mnementh
well I am using this tutorial: http://www.netbeans.org/kb/articles/tutorial-applets-40.htmlIt does basically ask me to add a java applet class from the create new file, which I'm doing, then copying and pasting in the source code into it. The class I copy into it does extend applet
meds
+2  A: 

The way applets work in Netbeans is annoying to me. The suggested usage from the help is to run the applet as you indicate you did (Run File). NetBeans will produce an HTML file under build/classes that references the applet. You then copy the HTML file to src where your class is. You can then tweak the HTML and in subsequent runs NetBeans will use your HTML file instead of generating it. Every time you run the file NetBeans opens the applet viewer program that ships with Java. You cannot control any of the arguments passed to the applet viewer. It ignores the run-time parameters you configure in the project. To change the parameters passed to the applet you must edit the HTML file manually.

A better way is to use the AppletWindow classes created over at the BlueJ project. It lets you host an applet on a JFrame, which means you can make a small standalone Swing app which calls your applet. The program then has a main method, you can launch an extra Swing window with buttons and text controls to simulate javascript calls to the applet and you can tweak the attributes that get passed to the applet at runtime. It's very nice for trying out new things in your code.

Links:

sjbotha