Friday, February 4, 2011

Setting classpath when compiling/running Java

Set the CLASSPATH environment variable to
- the directories having .class files
- the .jar files which contain relevant .class files

Then run javac and java; it will pick required the .class files from its location.

If you say
export CLASSPATH=dir1
and the .class file is dir1/dir11/abc.class, then you must say
java dir11.abc
to enable java to find abc.class.

No comments:

Post a Comment