Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Monday, November 19, 2007

Compiling and running java packages from a command line

To compile the above example, you must be outside the packagetest directory. To compile the classes:

   javac packagetest/ClassB.java
javac packagetest/ClassA.java
To run the main program in ClassA.
   java packagetest.ClassA
or
   java packagetest/ClassA

In windows the "/" can be replaced by the "\" in the javac command, but not in the java command. Generally use a forward slash ("/") because it is used more commonly than the backslash in other places as well.

No comments:

Post a Comment

Archives