[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 420
  • 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)

2 Solutions
  java -cp HCL.jar <yourmainclass>
java -jar HCL.jar
   would work if you downloaded a more recent version of Java.
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.
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Siva Prasanna KumarPrincipal Solutions ArchitectCommented:

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.

>> and as such you just need to specify the  class path & execute this command.
already said in my first comment
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
Nellios, see asker's question :
>> Warning: -jar not understood. Ignoring.

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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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