Java Reference
In-Depth Information
7.4.2
For contrast, Example 7.2 shows compiling a multiclass program that is
contained in a package (it is the Payback debt/savings/purchase calculator). 12
Compiling a Multiclass Program
Example 7.2 Compiling and running a multiclass program
$ cd payback/src
$ gcj -o payback -I. --main=net.multitool.Payback.Payback \
net/multitool/Payback/Payback.java
$ ./payback
Payback -- A savings/credit comparison tool
Copyright (C) 2003 by Carl Albing and Michael Schwarz
Released under the GNU/GPL. Free Software.
...
...
...
etc.
The -I switch names a directory that is to be prepended to the classpath.
In this case, we added “ . ” which is the source directory for the Payback
program. 13 Notice the package elements expressed with dots for the --main
argument, and with slashes for the filename argument.
NOTE
The gcj compiler does pick up and use the CLASSPATH environment variable
if it is specified. Also, gcj has a number of switches besides -I for classpath
manipulation. We won't cover those here; -I is the preferred method (according
to the gcj manpage at any rate).
12. Since this chapter was written, XML features were added to Payback that make it no longer
work with gcj .
13. The Payback code can be found at the topic's Web site: http://www.javalinux-
book.com/ .
Search WWH ::




Custom Search