Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a JAR file, which has many dependencies (ApacheCommons stuff mostly). When I put all those JAR's in the same directory as my main JAR, everything works fine. But that makes a mess and it also means that people have to carry all those external libraries around whenever they move my program's JAR on their system.

So I put them all in a separate directory and added that directory's path to CLASSPATH environment variable (using /etc/environment). Now even though echo $CLASSPATH returns that path, still running my JAR without those libraries in the same directory causes java.lang.NoClassDefFoundError (which happens when it can't find external JARs needed).

Any help/ideas would be highly appreciated.

share|improve this question

This is not really a ubuntu-Problem, see this question on stackoverflow.

The CLASSPATH-Variable does not list pathes to jar-files, but pathes to Java-class-files. To include a jav-file in a classpath you have to put jar-file filename in the classpath (e.g. CLASSPATH=/path/to/some/jar/file/jarfile.jar).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.