Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Java: NoClassDefFoundError. WTf?

Options
  • 25-02-2003 3:48pm
    #1
    Registered Users Posts: 68,317 ✭✭✭✭


    OK, in an attempt to solve this problem, I'm trying to move the project to a linux box.

    Compiles fine, all the files in the project are in the same package (and correct directory), but when I go to run the testbench, I get

    Exception in thread "main" java.lang.NoClassDefFoundError: test/class

    And I'm stumped. The test file is included as part of the package, and only has a main method. Nothing more. Have no idea what's going on.

    [Sorry for spamming the programming board :)


Comments

  • Registered Users Posts: 1,186 ✭✭✭davej


    Without more information it's a bit difficult to tell, but it's almost certainly a problem with the way you've defined your package and the location the class files get compiled into..

    it's also possible (seeing as you mention that you moved platforms) that you may have compiled with for example, Javac 1.4 but ran with Java 1.3 and used some new class only available in Java 1.4.

    davej


  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    It's grand, I got it sorted. You can't call a program inside a package in the normal (java test.class) way.

    You have to call the entire path, ie

    java -classpath ./whereispackage/ com.mypackage.test

    :)

    (For some reason I can't delete this thread :()


  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    Originally posted by seamus
    It's grand, I got it sorted. You can't call a program inside a package in the normal (java test.class) way.

    You have to call the entire path, ie

    java -classpath ./whereispackage/ com.mypackage.test

    :)

    (For some reason I can't delete this thread :()

    Because deleting is bad, and someone else may have the same problem.

    Actually that's a common trip up problem, along with defining main() as a method rather then a main() method.


  • Registered Users Posts: 173 ✭✭happydude13


    it is a good idea also to use java.FileSeperator for cross platform stuff.

    manys the month that has been wasted,


  • Closed Accounts Posts: 6 smitzer


    So did it work properly on the linux box after moving it?


  • Advertisement
  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    So did it work properly on the linux box after moving it

    Yep \o/


Advertisement