Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Running JAVA on linux

  Asked By: Viveka    Date: Feb 22    Category: Java    Views: 1029
  

When I try to compile anything I get the following error "Execption
in thread "main" Java.lang.NoClassDefFoundError:" I added the
directory where the javac is located to my PATH. Is there anything
else I have to do.

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Murad Bashara     Answered On: Feb 22

I had a similar problem. This is how I fixed it.

I set my path  with this command:

export PATH=$PATH:/usr/local/jdk1.3/bin

It sounds like you did this already.

Then, I had to set the CLASSPATH.

CLASSPATH is specific to java  and is meant to allow the Java
Virtual Machine (the "java" command is the JVM) to find the
classes needed by your Java program. It already knows about the
API's classes; it needs to know about any others that you use.
With simple Java programs, all you need to do is tell it to use the
current directory:

export CLASSPATH=.:$CLASSPATH

I used the current directory "." first to make sure it resolves
classes
from my current directory first.

You can also specify classpaths on the java command line:

java -classpath .:$CLASSPATH myapp

 
Didn't find what you were looking for? Find more on Running JAVA on linux Or get search suggestion and latest updates.




Tagged: