Use the -classpath command-line option:
javac -classpath library.jar MyProgram.java
And then, to run it, specify the class path again - including where your actual code is:
java -classpath library.jar;. MyProgram
(Suppose you are using Windows. On Unix, use: instead, as a path separator.)
source
share