Showing posts with label class-path. Show all posts
Showing posts with label class-path. Show all posts

Sunday, December 12, 2010

Dealing with external jar files on command prompt

I had a problem with compiling and running a java file in command line where it imports an external jar files. Here is the solution I've found.

Compilation

javac -cp <path to where the source codes resides>;<path to where the jar file resides> Example.java

run

java <path to where the source codes resides>;<path to where the jar file resides> Example <command-line arguments if any>

Note 1:  separator ; for windows and : for unix
Note 2:  multiple jar files can be used delimited by ;
Note 3:  . can be used to specify the current directory