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.
Save the file as HelloApp.java & compile it with the following...
Run it with the following...
If you want to generate documentation using JavaDoc just type the following...
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.
Then create the Jar file by typing the following...
Run the Jar file with the following...
public class HelloApp
{
public static void main(String[] args)
{
System.out.println("Hello, World!");
}
}
Save the file as HelloApp.java & compile it with the following...
javac HelloApp.java
Run it with the following...
java HelloApp
If you want to generate documentation using JavaDoc just type the following...
javadoc -d docs HelloApp.java
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
No comments:
Post a Comment