Java Reference
In-Depth Information
-cp ) to tell the interpreter where to look for the classes needed by the program.
Consider the following command:
java - classpath / opt / Jude com . davidflanagan . jude . Jude datafile . jude
java is the command to run the Java interpreter. -classpath /usr/local/Jude
tells the interpreter where to look for .class files. com.davidflanagan.jude.Jude is
the name of the program to run (i.e., the name of the class that defines the main()
method). Finally, dataile.jude is a string that is passed to that main() method as the
single element of an array of String objects.
There is an easier way to run programs. If a program and all its auxiliary classes
(except those that are part of the Java platform) have been properly bundled in a
Java archive (JAR) file, you can run the program simply by specifying the name of
the JAR file. In the next example, we show how to start up the Censum garbage col‐
lection log analyzer:
a x
java - jar / usr / local / Censum / censum . jar
Some operating systems make JAR files automatically executable. On those systems,
you can simply say:
% / usr / local / Censum / censum . jar
See Chapter 13 for more details on how to execute Java programs.
Summary
In this chapter, we've introduced the basic syntax of the Java language. Due to the
interlocking nature of the syntax of programming languages, it is perfectly fine if
you don't feel at this point that you have completely grasped all of the syntax of the
language. It is by practice that we acquire proficiency in any language, human or
computer.
It is also worth observing that some parts of syntax are far more regularly used than
others. For example, the strictfp and assert keywords are almost never used.
Rather than trying to grasp every aspect of Java's syntax, it is far better to begin to
acquire facility in the core aspects of Java and then return to any details of syntax
that may still be troubling you. With this in mind, let's move to the next chapter and
begin to discuss the classes and objects that are so central to Java and the basics of
Java's approach to object-oriented programming.
Search WWH ::




Custom Search