Imported Java applet project into netbeans won't work, Netbeans refuses to identify or even find main class even when manually set

StackOverflow https://stackoverflow.com/questions/665820

Question

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.

Was it helpful?

Solution

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:

OTHER TIPS

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.

Shift + F6 worked for me in NetBeans 7.3.1

I edited to allow webstart in properties first.

Im using a single applet from Schiltds complete java 7th edition page 626 simple Banner Applet.

I'm glad to give a little back.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top