Most notable is what it does not contain:
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/java/jdk1.1.5/bin/javac
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class ShowD extends Applet implements ActionListener {
Label prompt;
TextField input;
double val;
public void init() {
prompt = new Label("Enter a number");
add(prompt);
input = new TextField(20);
input.addActionListener(this);
add(input);
setBackground(Color.cyan);
}
public void paint(Graphics g) {
g.drawString("The number is: "+val,50,80);
g.drawString("One hundred times the value is: "+100*val,50,110);
g.drawString("This program was modified by Steven Robbins",50,150);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == input) {
val = Double.valueOf(input.getText()).doubleValue();
repaint();
}
}
}
Compile this with:This creates a file called ShowD.class
Run this using:
appletviewer ShowD.java
Put it on the web!