Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Wayne Crawford   on Sep 29 In Java Category.

  
Question Answered By: Rene Sullivan   on Sep 29

You may know this already so I'm sorry if I'm insulting your intelligence,
but the first thing that comes to my mind is to check your classpath. The
environment variable called "CLASSPATH" needs to be set, and it needs to
contain at least 1 path: the "lib" directory under your SDK install
directory. For instance, if you installed the SDK under C:\j2sdk1.4.1\,
your CLASSPATH should be set to "C:\j2sdk1.4.1\lib".

Plus, when you run your "hello java" application, you need to make sure the
classpath ALSO includes the directory where your HelloJava1.class file
exists. Rather than add this to your environment variable, you can just
set this at the command line (when you run "java") by using the -classpath
switch. For example, say you're HelloJava1.class path is in the
C:\programs\Java\ directory. You'd run java  like this:

On Windows:
java -classpath %CLASSPATH%;C:\programs\Java\ HelloJava1

If you're running Linux, of course the directory names will be different,
such as:
java -classpath $CLASSPATH:~/programs/Java/ HelloJava1

Hope this helps. Again, sorry if this is all old news to you, but that's
what I've gotten stuck on before. class  paths can be tricky (for me anyway).

Share: 

 

This Question has 11 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on error: java.lang.NoClassDefFoundError Or get search suggestion and latest updates.


Tagged: