We can now compile and run an HPJava program.
As a first example, go to the subdirectory hpjdk/examples/fft2d/
(or the nested folder
hpjdk\examples\fft2d\, under Windows).
This contains a fairly sophisticated little program that
combines a parallel algorithm for 2-dimensional Fourier Transform
(discussed in section 4.1) with a simple
Java Swing graphical user interface.
The main program is in the file Wolf.hpj. Compile the
whole program by issuing the command
You can now run the program by issuing the command
A small Swing window should appear. Click to load the input file. A new window containing a picture of a wolf should appear. You can experiment with the image, exploring the effect of deleting different numbers of modes in Fourier space. The windows are illustrated in Figure 1.1.
In general running the hpjavac command generates one or more standard Java class files that can be executed by a standard Java Virtual Machine, or, as we will see later, by more than one JVM. (Section 2.7 describes how to run HPJava code on multiple JVMs, and thus on multiple computers.)
The source files passed as arguments to the hpjavac are normally HPJava programs with file extension ``.hpj'' (they can also be ordinary Java source files with extension ``.java'').
The hpjavac command is actually implemented as a preprocessor. Every HPJava source program is converted to an intermediate Java file. These intermediate files are then fed to the standard javac compiler. If you look in the fft2d/ directory after successfully running the hpjavac command you will find several intermediate Java files. You can study the content of these files if you are interested. They typically contain sections of recognizable Java code from the source file, interspersed with some very long lines produced by translating the extended syntax. The preprocessor works hard to preserve the line numbering of the input file, to make debugging easier. Generally speaking it is a bad idea to manually edit these automatically generated files.