Sunday, July 11, 2010

To execute a java program

I don’t know that a java program can be executed in two ways. Here we go:

First Method

Compile java source into java byte code, and then execute it right from the byte code.

javac -sourcepath src -d build\classes src\org\huahsin68\
java -cp build\classes org.huahsin68.HelloWorld

Second Method

Build a jar file from the byte code and then execute it from the jar.

jar cfm build\jar\HelloWorld.jar myManifest -C build\classes .
java -jar build\jar\HelloWorld.jar

No comments: