hey everyone,

i am a new developer using the bluej IDE on mac 10.6. Whenever i use the virtual terminal to execute, it works perfectly. the other day, i attempted to export the file to a JAR file through the programs basic functionality, as JAR files are natively run on macs. Everything works fine, I define the main class, include the source code, it exports with no problem. However, whenever i try to launch it, i get the error message:

"The Java JAR file "Pythagorean.jar" could not be launched. Check the console for possible error messages."

So i tried launching it using the java (file path) command, and i get the following error;

"Exception in thread "main" java.lang.NoClassDefFoundError: /Users/tstacey95/Desktop/Pythagorean/jar
Caused by: java.lang.ClassNotFoundException: .Users.tstacey95.Desktop.Pythagorean.jar
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

Please help, as i am anxious to get the file exported and ready for distribution as a JAR file.

It looks like you left off the -jar option with the java command.
The missing class in the message looks like the path to the jar file:
.Users.tstacey95.Desktop.Pythagorean.jar

For executing jar files use the -jar option on the command line:
java -jar Pythagorean.jar

tried that, got the error message:


Exception in thread "main" java.lang.NoSuchMethodError: main

Does the jar file contain a manifest file? Does the manifest file have a line with:
Main-Class: ? What follows the Main-Class: ? That should be the name of the class with the main method. If the Main-Class: entry has a class name, does that class have the correctly formatted main method?

Does the jar file contain a manifest file? Does the manifest file have a line with:
Main-Class: ? What follows the Main-Class: ? That should be the name of the class with the main method. If the Main-Class: entry has a class name, does that class have the correctly formatted main method?

the MANIFEST.MF file is the META-INF folder was as such:

Manifest-Version: 1.0
Class-Path:
Main-Class: Pythagorean

yes, it runs perfectly in the virtual terminal. the problem is when i try to export it

Please show the ALL of the console with the problem when you try to execute the jar file.

ok, strange occurrence. after re-trying the java -jar command, the program launched. however, it will not launch through the JAR launcher method

it will not launch through the JAR launcher method

What is the 'JAR launcher method'? Is it an IDE menu item?

This article has been dead for over six months. Start a new discussion instead.