Results 1 to 8 of 8
  1. #1
    jallmer is offline Member
    Join Date
    Sep 2009
    Posts
    4
    Rep Power
    0

    Default Class is there but NoClassDefFoundError

    Dear Experts,
    lately I keep running into the same problem over and over again.
    I have several projects and reference them via their jar files in order to use their classes.
    All projects are in one folder and the references are relative.

    While compiling everything works fine when running or debugging the program I get something like:
    Exception in thread "main" java.lang.NoClassDefFoundError: sequences/AminoAcids as soon ad the first line referencing AminoAcids is hit.
    The class exists in the given location and has recently been build so there should be no problem.
    Also other classes in the same jar file do not have the same problem.

    I fixed the problem before by renaming the packages and rebuilding and other strange approaches.
    Please tell me a proper way to solve this problem.

    There may be a relation to me using SVN and although having the same directory structure on all the computers
    something might cause this problem via this path.

    How do I fix such a problem without having to use strange approaches like renaming of packages etc.
    Thanks

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    Open up the jar file at the reported location and see if the class really is there.
    If the class is not there then your build settings are to blame.

  3. #3
    jallmer is offline Member
    Join Date
    Sep 2009
    Posts
    4
    Rep Power
    0

    Default

    Unfortunately, the class is actually in the jar file.

    What else could be the problem?

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    The jar is somehow missing from the class path at run time.
    Are you perhaps using some custom class loaders e.t.c.

  5. #5
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    808
    Rep Power
    6

    Default noclassdeffounderror

    Try this and tell if it works:

    Executing your program using this command should correct the problem:
    java -classpath . helloworld

    where helloworld is the name of your compiled class.

    OR

    place '.' as part of your environment variable CLASSPATH

    This tells java that your classpath is your local directory.
    Ramya:cool:

  6. #6
    jallmer is offline Member
    Join Date
    Sep 2009
    Posts
    4
    Rep Power
    0

    Default

    Could there be a problem because I have the same project
    in the same folders on several computers and use SVN?
    I have the src and the nbproject folders of each project on the repository.
    Could having the nbproject folder on the rep corrupt my projects?

    Where in Netbeans could I set the classpath?
    And which project should set the classpath (AminoAcids class is in Sequences)?

    Projects (not classes) are:

    Sequences <- Helpers

    MassSpecLib <- Helpers
    MassSpecLib <- Sequences

    MSResultLib <- Helpers
    MSResultLib <-Sequences
    MSResultLib <- MassSpecLib

    MSMSFragmentation <- Helpers
    MSMSFragmentation <- MassSpecLib
    MSMSFragmentation <- MSResultLib

  7. #7
    jallmer is offline Member
    Join Date
    Sep 2009
    Posts
    4
    Rep Power
    0

    Default

    Quote Originally Posted by r035198x View Post
    The jar is somehow missing from the class path at run time.
    Are you perhaps using some custom class loaders e.t.c.
    I am not and wouldn't know how ;)

  8. #8
    aaroncarpet's Avatar
    aaroncarpet is offline Senior Member
    Join Date
    Nov 2009
    Location
    California
    Posts
    147
    Rep Power
    0

    Default

    sometimes with fields you need to include the class that owns the field (i. e. JOptionPane.YES_OPTION).......

Similar Threads

  1. Replies: 2
    Last Post: 01-20-2014, 07:45 AM
  2. Message NoClassDefFoundError
    By karim in forum Eclipse
    Replies: 1
    Last Post: 03-20-2009, 03:43 PM
  3. Getting NoClassDefFoundError through quicktime API
    By sunil.mact in forum Advanced Java
    Replies: 3
    Last Post: 01-23-2009, 02:59 PM
  4. java.lang.NoClassDefFoundError
    By bizmut in forum Eclipse
    Replies: 3
    Last Post: 06-15-2008, 12:54 AM
  5. NoClassDefFoundError
    By jon80 in forum New To Java
    Replies: 3
    Last Post: 05-18-2008, 12:20 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •