Compiling java file with jar file on command line

. means current directory
: filepath separator on nix os
; filepath separator on windows

With these in one directory. No package declaration on the first line in


To compile and run

javac -Xlint -cp somejar.jar *.java
java -cp .:somejar.jar Hello

With these in the application root directory. With package com.hello; on the first line in


To compile and run

javac -d bin -sourcepath src/com/hello -Xlint -cp lib/somejar.jar src/com/hello/*.java
java -cp bin:lib/somejar.jar com.hello.Hello

Search within Codexpedia

Custom Search

Search the entire web

Custom Search