NoClassDefFound Error

Posted on 2006-04-13
Last Modified: 2008-02-01
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 (/usr/lib/
   at _Jv_ThreadRun(java.lang.Thread) (/usr/lib/
   at _Jv_RunMain(java.lang.Class, byte const, int, byte const, boolean) (/usr/lib/
   at __gcj_personality_v0 (/root/HCL/dist/java.version=1.4.2)
   at __libc_start_main (/lib/tls/
   at _Jv_RegisterClasses (/root/HCL/dist/java.version=1.4.2)

Question by:pradapkumar
    LVL 13

    Assisted Solution

      java -cp HCL.jar <yourmainclass>
    LVL 13

    Expert Comment

    java -jar HCL.jar
       would work if you downloaded a more recent version of Java.
    LVL 10

    Expert Comment

    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.
    LVL 23

    Accepted Solution


    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 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.

    LVL 13

    Expert Comment

    >> and as such you just need to specify the  class path & execute this command.
    already said in my first comment
    LVL 10

    Expert 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
    LVL 13

    Expert Comment

    Nellios, see asker's question :
    >> Warning: -jar not understood. Ignoring.

    -> java don't recognize -jar option
    -> classpath needed
    LVL 24

    Expert Comment

    Nellios, that's the second time; I warn you.
    LVL 30

    Expert Comment

    BTW, where is HCL.jar located? Has it even been distributed or not?

    Featured Post

    Gigs: Get Your Project Delivered by an Expert

    Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

    Join & Write a Comment

    By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
    Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
    Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
    Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now