272Chapter9 • Platform Independent Development with Java
import java.applet.*;
import java.awt.*;
public class HelloWorld extends java.applet.Applet {
public void paint (java.awt.Graphics gc) {
gc.drawString("Hello World", 100, 90);
}
}
The main thing to note here is that compiling Java applets is not different in any way from
compiling Java applications. The only difference between a Java application and a Java applet is
in the source code.
9.7Testing Applets with Netscape
As mentioned earlier, a Java applet must run inside a browser. For this you have to write an
HTML file. The following HTML file incorporates the applet and can be loaded to a browser
like Netscape.
When you load this file in the browser, the browser will execute the Java code and you can
see the “Hello World” message printed in the browser window. Applets can also be viewed by
applet viewers.
9.8Jikes for Java
Jikes is an open source compiler for Java from IBM. It is fully compatible with the Java Lan-
guage Specifications. You can download it from its web site at http://oss.software.ibm.com/
developerworks/opensource/jikes/. Jikes version 1.15 is available right now. You have to down-
load and install it the usual way. Typical steps are:
•Download it from its web site.
•Uncompress it using
tar –zxvf jikes-1.15.tar.gz
command.
•Go to
jikes-1.15
directory.
•Run the configure script using the
./configure
command.
•Run the
make
command.
•Run the
make install
command.