Monday, 13 April 2009

Java HelloApp Program

I've recently been using Java again, so I thought I'd present some simple programs you can run in Java. Just type the following into a text editor but be careful because Java is case sensitive. Certain commands are expected to be entered using upper case letters.

public class HelloApp
public static void main(String[] args)
System.out.println("Hello, World!");

Save the file as & compile it with the following...


Run it with the following...

java HelloApp

If you want to generate documentation using JavaDoc just type the following...

javadoc -d docs

Finally, if you'd like to place your class in a Jar file, you must first create a Manifest file. Just place the following text in a file called Manifest.txt & make sure you place a newline at the end.

Main-Class: HelloApp

Then create the Jar file by typing the following...

jar cvfm HelloApp.jar Manifest.txt *.class

Run the Jar file with the following...

java -jar HelloApp.jar

Bookmark and Share
Post a Comment