PDA

View Full Version : Need Help With Jar File


Ioncannon
18-03-2007, 08:48 PM
So I finally finished coding my text engine in java and create the jar file to show a friend. It works correctly on my PC but on his Virtual Machine spits out a "Cannot find main class" error message. Only difference between the two computers is I have the java dev kit. I tested it on other computers w/o the JDK (but they have the JRE) and same error happens. Is something incorrect in the manifest, or is it my code? Can anyone help with this?

Attached is both the current JAR and the java files (Sorry if the code looks extremely messy >.<):

nitro
19-03-2007, 06:48 AM
I also get this error. I don't know what is wrong but when I start it from the command line I get a different error:
$ java -jar textg.jar
java.lang.UnsupportedClassVersionError: Bad version number in .class file
********at java.lang.ClassLoader.defineClass1(Native Method)
********at java.lang.ClassLoader.defineClass(Unknown Source)
********at java.security.SecureClassLoader.defineClass(Unknow n 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"


Which JDK version did you use to compile this program?

EDIT:
I just recompiled and repackaged your code with the same manifest so that's not your problem. I did get a notice during the compilation
Note: GUI_Textg.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.


I think something strange has happened when you compiled the program.
BTW I'm using Sun JDK 1.5.0_09

Ioncannon
19-03-2007, 09:47 PM
JDK 1.6.0

nitro
20-03-2007, 04:42 PM
I downloaded and installed JDK 1.6.0 and now I can run your jar file. I think the problem is with different version of java. You should check the computer that doesn't work for which Java version it has.

STFM
22-03-2007, 05:25 AM
Yeah you cant always run newer java programs with older runtimes