How to set the environment variables for Java in Windows (the classpath)?
Keep in mind that the %CLASSPATH%
environment variable is ignored when you use java/javac in combination with one of the -cp
, -classpath
or -jar
arguments. It is also ignored in an IDE like Netbeans/Eclipse/IntelliJ/etc. It is only been used when you use java/javac without any of the above mentioned arguments.
In case of JAR files, the classpath is to be defined as class-path
entry in the manifest.mf file. It can be defined semicolon separated and relative to the JAR file's root.
In case of an IDE, you have the so-called 'build path' which is basically the classpath which is used at both compiletime and runtime. To add external libraries you usually drop the JAR file in a (either precreated by IDE or custom created) lib
folder of the project which is added to the project's build path.