Including jars in classpath on commandline (javac or apt)

Solution 1:

Try the following:

java -cp jar1:jar2:jar3:dir1:. HelloWorld

The default classpath (unless there is a CLASSPATH environment variable) is the current directory so if you redefine it, make sure you're adding the current directory (.) to the classpath as I have done.

Solution 2:

In windows:

java -cp C:/.../jardir1/*;C:/.../jardir2/* class_with_main_method

make sure that the class with the main function is in one of the included jars

Solution 3:

Note for Windows users, the jars should be separated by ; and not :.

for example: javac -cp external_libs\lib1.jar;other\lib2.jar;