• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 428
  • Last Modified:

NoClassDefFound Error

I have developed an application using netbean IDE in Linux  and it works fine , when I distribute the application as jar file and when i execute the same then i get NoClassDefFound error .I am  posting the error message as well for help.
Thanks in advance

[root@node2 dist]# java -jar "HCL.jar"
Warning: -jar not understood. Ignoring.
Exception in thread "main" java.lang.NoClassDefFoundError: HCL.jar
   at gnu.gcj.runtime.FirstThread.run() (/usr/lib/libgcj.so.5.0.0)
   at _Jv_ThreadRun(java.lang.Thread) (/usr/lib/libgcj.so.5.0.0)
   at _Jv_RunMain(java.lang.Class, byte const, int, byte const, boolean) (/usr/lib/libgcj.so.5.0.0)
   at __gcj_personality_v0 (/root/HCL/dist/java.version=1.4.2)
   at __libc_start_main (/lib/tls/libc-2.3.4.so)
   at _Jv_RegisterClasses (/root/HCL/dist/java.version=1.4.2)





0
pradapkumar
Asked:
pradapkumar
2 Solutions
 
WebstormCommented:
try:
  java -cp HCL.jar <yourmainclass>
0
 
WebstormCommented:
java -jar HCL.jar
   would work if you downloaded a more recent version of Java.
0
 
NelliosCommented:
When you create a jar file there is a file called MANIFEST.MF inside it and you can see it if you extract the jar content with any zip managment software.

In that file the classpath is added. Your problem is that inside this file you have insufficient classpath information.

1) Extract that file & check it
2) Search your IDE help on how to determine the classpath on the jarfiles it generates.

if the classpath is ok, then it is something wrong with the classes.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
http://www.cs.usfca.edu/~parrt/course/601/lectures/java.tools.html

check out this link.

and as such you just need to specify the  class path & execute this command.

java -classpath HCL.jar SomeMain

Where in the above example SomeMain.java is the class which has a Main method in it.

if there are multiple files in ur jar which have main main function in it the you need to explicitly specify the class which
you want to execute and if there is any package inside a jar then you need to specify the package name too like.

java -classpath HCL.jar shiva.SomeMain

where in above shiva is the package name & SomeMain is the class inside it.

0
 
WebstormCommented:
>> and as such you just need to specify the  class path & execute this command.
already said in my first comment
0
 
NelliosCommented:
Webstorm. It is not required to specify the classpath in the command line.
As soon as all the required classes are included in the jar, the proper way to do it is the CLASSPATH directive inside MANIFEST.MF file
0
 
WebstormCommented:
Nellios, see asker's question :
>> Warning: -jar not understood. Ignoring.

-> java don't recognize -jar option
-> classpath needed
0
 
sciuriwareCommented:
Nellios, that's the second time; I warn you.
0
 
Mayank SAssociate Director - Product EngineeringCommented:
BTW, where is HCL.jar located? Has it even been distributed or not?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now