Running a .jar file (as an executable) on my machine (where I run JGrasp with the SDK loaded) I have no problem. When I post the .jar on my intranet server and download it to a machine where I have only the JRE installed, it is seen as a .zip file and gives me the error message "Could not find the main class. Program will exit" when I double click it, even after I change the name from xxxx.zip to xxxx.jar.
I think that the manifest file is correct because the .jar runs ok with double-clicking on the "full java" machine. Any suggestions?
Open the file with Winzip or some other editor and inspect the manifest file. Renaming from jar to zip and back shouldn't change the contents of the file.
Have you tried manually entering: java.exe -jar xxxx.jar
Copy and post the contents of the console with the commandline and the error messages so we can see what's happening.
Joined: Oct 10, 2005
The (working on my machine) manifest file points at MBSGUI as the file with the main method. I used the following command to execute the MBSimulation.jar file:
java.exe -jar MBSimulation.jar
The error thrown is as follows:
java.lang.UnsupportedClassVersionError: MBSGUI (Unsupported major.minor version 49.0) at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$100(Unknown Source) 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) Exception in thread "main"
That error means that the class files are newer than the JVM you're trying to run them on. 49.0 is the version that Tiger (Java 5) produces; any earlier JVM (like version 1.4) will print an error message like this and be unable to load the program.
If you're using Tiger features, you can only run on a Tiger JVM. Alternatively, if you're not, you can compile with the "-source 1.4" command line arguments to javac to produce backward-compatible class files.
Thank you, folks, both for listening and giving such good advice. Updated the JRE to 1.5 (or is it 5.0?) and all ran beautifully. Had to change the file name from xxxx.zip to xxxx.jar, but that is small cheese. Again, thanks... cheers! Bill