Java is a programming language which is
and most importantly ...
Java is like C and C++ in a number of ways.
Most notable is what it does not contain:
Make sure your path includes:
/usr/local/src/inet/JDK/java/bin
Compile with
javac programname.java
Run applications with
java programname
Run applets with
appletviewer programname.java
This assumes that your java source has an HTML heading as a comment.
Test to see that your path is set correctly by executing:
which javac
Ther result should be:
/usr/local/src/inet/JDK/java/bin/javac
In a clean directory, create a file called HelloWorld.java:
class HelloWorld {
public static void main(String args[]) {
System.out.println("Hello World!");
}
}
Compile this with:
javac HelloWorld.java
This creates a file called HelloWorld.class
Run this using:
java HelloWorld
The output will be:
Hello World!
In a clean directory, create a file called HelloWorld.java:
import java.awt.*;
import java.applet.*;
public class HelloWorldApplet extends Applet {
public void paint(Graphics g) {
g.drawString("Hello World!", 20, 20);
}
}
Compile this with:
javac HelloWorld.java
This creates a file called HelloWorld.class
Run this using:
appletviewer HelloWorld
This will create a window containing:
Hello World!
starting at position with (x,y) coordinates (20,20).
(0,0) is the upper left corner.