Saturday, February 16, 2013

Compiling and running Java program

Suppose we have Hello.java file in the folder D:/myprogram/com/example/ and the package of the Hello class is com.example.



Compiling

D:> javac myprogram\com\example\Hello.java
and then the Hello.class file will be created in the same folder as Hello.java.

If your program is using third-party libraries and they are in D:\myprogram\libs, then:
D:> javac -cp "D:\myprogram\libs" myprogram\com\example\Hello.java



Running

D:> java -cp "D:\myprogram" com.example.Hello

If there are third-party libraries in D:\myprogram\libs folder, then:
D:> java -cp "D:\myprogram\libs\*;D:\myprogram" com.example.Hello







No comments:

Post a Comment