I've set the CLASSPATH, but I still get a noClassDefFoundError. (Java)
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I've set the CLASSPATH, but I still get a noClassDefFoundError. (Java)
I'm having trouble with my latest Java project. I've compiled other Java programs before, but I'm using packages in my latest program, and I've never done that before.
First, I set the CLASSPATH to ".:.\view\:.\model\" because I've got other classes in the "view" and "model" directories. (I put backslashes in the classpath because I'm using Windows to do this.)
I can compile all of my files, but when I go to run the program, it says 'Exception in thread "main" java.lang.NoClassDefFoundError: pc' (pc is the name of the main class).
Um.... You mean it matters? I thought Java was the same on either platform. So, do you think this is a Windows problem or a Java problem?
And what is $env, anyway? I did a bit of searching on Google and I couldn't find anything about it. I would assume it has something to do with the environment, right?
The default value of the CLASSPATH is c:\PJAVA, but I've been overwriting it. I never knew that it had a default value until now. All that is in PJAVA is a file called error.log.
Java is installed in "c:\j2sdk1.4.2_02\".
The classes are in:
c:\WINODWS\Desktop\Travis\Java\window thing\ym\
c:\WINODWS\Desktop\Travis\Java\window thing\ym\view\
c:\WINODWS\Desktop\Travis\Java\window thing\ym\model\
Which directory are you actually in when you try to execute them?
c:\WINODWS\Desktop\Travis\Java\window thing\ym\
What packages are your classes in, and are they in the same directory structure as the package structure?
pc.class (the main one) is in ym. The classes in .\model\ and .\view\ are members of ym.model and ym.view, respectively.
What are you overwriting CLASSPATH to?
".:.\model\:.\view\"
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.