Java not finding libraries in CLASSPATH
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
).
Related videos on Youtube
lfk
Updated on September 18, 2022Comments
-
lfk over 1 year
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 thoughecho $CLASSPATH
returns that path, still running my JAR without those libraries in the same directory causesjava.lang.NoClassDefFoundError
(which happens when it can't find external JARs needed).Any help/ideas would be highly appreciated.