Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JRE doesn't find the main class inside a JAR archive file

843798May 24 2008 — edited May 25 2008
Hello everybody,

I've written a small application in Java, using NetBeans. Running my application inside NetBeans works fine, but I can't run it from the console or by double clicking the jar file.
Running it from the console I get the following error message:
 java -jar TestApplication.jar
Exception in thread "main" java.lang.NoClassDefFoundError: tst.Benchmark
   at gnu.java.lang.MainThread.run(libgcj.so.81)
Caused by: java.lang.ClassNotFoundException: tst.Benchmark not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:TestApplication.jar], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
   at java.net.URLClassLoader.findClass(libgcj.so.81)
   at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.81)
   at java.lang.ClassLoader.loadClass(libgcj.so.81)
   at java.lang.ClassLoader.loadClass(libgcj.so.81)
   at gnu.java.lang.MainThread.run(libgcj.so.81)
I know that these errors often come when the class path is not set in the right way, and using a single java file, you can fix this by passing the parameter "-cp ."
I tried this with the jar file but it does not work and using "-cp TestApplication.jar tst/Benchmark" didn't work either.

Inside the jar file I have the META-INF Folder and a "tst" Folder which contains all my class files. And I've set tst.Benchmark as the main class, this also stands in the manifest file correctly.

Do you have any ideas what could be wrong?


Greetings JavanianGuy
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 22 2008
Added on May 24 2008
2 comments
288 views