Results 1 to 7 of 7
- 05-18-2011, 05:18 PM #1
Member
- Join Date
- May 2011
- Posts
- 6
- Rep Power
- 0
Error in jar file but not when program is run as standalone
Hello,
I created a program in java when i compile it javac filename.java and run it java filename using the command line it runs perfectly. The problem I am having is when i make a jar file using this command line jar cfm filename.jar man.tx filename.class filename.png it creates the jar file filename.jar but when i try and run it using this command line java -jar filename.jar it gives me these errors:
Exception in thread "main" java.lang.NoClassDefFoundError: SchoolVue$1
at SchoolVue.RunSchool(SchoolVue.java:97)
at SchoolVue.main(SchoolVue.java:560)
Caused by: java.lang.ClassNotFoundException: SchoolVue$1
at java.net.URLClassLoader$1.run(URLClassLoader.java: 217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 19)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 64)
at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:332)
I've even created a manifest file that contains Main-Class: className and it still doesn't work.
Does anyone have a clue as to why this is happening?Last edited by lance9200@yahoo.com; 05-18-2011 at 05:20 PM. Reason: needed to include more information for better understanding
- 05-18-2011, 05:24 PM #2
- 05-18-2011, 05:31 PM #3
You have to include all .class files. Including those with names like filename$1.class, filename$1.class etc. Those are the class files for your anonymous inner classes.i make a jar file using this command line jar cfm filename.jar man.tx filename.class filename.png
But first, you should have looked at the stack trace.
What's on line 97 of SchoolVue.java? I'll bet there's a new ... statement which tries to instantiate the first declared anonymous inner class.... NoClassDefFoundError: SchoolVue$1
at SchoolVue.RunSchool(SchoolVue.java:97)
db
- 05-18-2011, 05:44 PM #4
Member
- Join Date
- May 2011
- Posts
- 6
- Rep Power
- 0
I give descriptions how I created the jar file in the original post as well as how I created the class file with javac. But here it is again:
jar cfm jarfile.jar man.txt classFile.class picture.png
line 97 is the end of an actionlistener { ); } i surrounded it in curly braces
- 05-18-2011, 05:46 PM #5
Member
- Join Date
- May 2011
- Posts
- 6
- Rep Power
- 0
When class file is created does it create a second class file with $1 appended to it?
- 05-18-2011, 05:48 PM #6
Member
- Join Date
- May 2011
- Posts
- 6
- Rep Power
- 0
Thank you very much I created a new jar file and include the name of class file with the $1 appended and it worked. Bless you. I've been trying to figure this out for 2 days.
- 05-18-2011, 06:31 PM #7
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Similar Threads
-
jar file ERROR:Could not find the main class. program will exit.
By Himanshu23 in forum AWT / SwingReplies: 3Last Post: 11-11-2010, 08:12 AM -
File upload from standalone client
By Astghik in forum Enterprise JavaBeans (EJB)Replies: 1Last Post: 01-12-2010, 02:07 PM -
java standalone to applet
By Nikohw in forum Java AppletsReplies: 1Last Post: 09-15-2009, 09:36 AM -
Standalone applications
By sachin2 in forum New To JavaReplies: 0Last Post: 07-21-2009, 08:08 PM -
could not find main class, the program wil exit-- error in jar file
By nishant.4545 in forum Advanced JavaReplies: 1Last Post: 07-03-2009, 08:41 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks