Java, fatal exception.

Does netbeans know where this main class is, it's a property of the project which it'll need to populate the manifest correctly when packaging it up into a jar.

When you run it from netbeans are you running the project or running the file?

Running the file works fine, but the project won't run.
 
In the projects window (Window->projects) you need to right click on whichever it is, choose properties from that pop up menu, go to the run section of the window that comes up there and set your main class. You should then be able to clean and build your project to get a runnable jar, and the project should run too :)
 
Now I can run the project in netbeans, but I get the error "Could not find main class", when trying to run the jar file.
 
And If I try to open it from the cmd prompt I get,

"Exception in thread "main" java.lang.NoClassDefFoundError: org/jdesktop/layout/GroupLayout$Group

Caused by: java.lang.ClassNotFoundException: org.jdesktop.layout.GroupLayout$Group

at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)"
 
That looks like your Java Runtime Environment (JRE) is not the correct version to run your program, the netbeans GUI builder uses features of Java 1.6 including GroupLayout which is what it's complaining about. Make sure that your runtime environmentis version 1.6 (Java 6) and that the paths are pointing to the 1.6 version and not the 1.5 or lower.
 
I have 1.6.0_3 and 1.6.0_4 installed. I get the same error when I tell it to use the java.exe 1.6.0_4 program to open the file.
 
Thank you so much, I have finally done it using that link to pack the swing-layout into my jar file by editing the build.xml file. :)
 
Back
Top Bottom