java in linux

by bharathi 2010-01-28 18:52:48

Writing and compiling Java program on linux

You need,

1. Java SE Development Kit 4 for linux version
2. A Text editor such as Pico, vi or emacs (all 3 are built in linux)

Now write a program using Pico, vi or emacs, let say you have given name as HelloWorldApp.java

Quote
class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}

(after installation java. environment variable will automatically register) you can verify these environmental variables by env or echo

Quote
JAVA_HOME=/usr/java/j2se
JAVA_FONTS=/usr/share/fonts/truetype
ANT_HOME=/usr/share/ant

Now compile using javac program,

Quote
javac HelloWorldApp.java

After running above program a file will be generated HelloWorldApp.class

Always remember both javac, and java are case sensitive, so HelloworldApp.java is not equal to helloworldapp.java.

Now simply run the program using java

Quote
java HelloWorldApp

The end...

Tagged in:

1005
like
0
dislike
0
mail
flag

You must LOGIN to add comments