Java Reference
In-Depth Information
Setting variable path. If you cannot execute any of the commands java , javac , javadoc , or
jar , you probably have not set your path correctly. We explain this for
Windows 2000; older windows systems are similar.
Your system contains a variable that lists directories with executable files
in them. Type " path" in a command-line window. The line that is printed con-
tains path names separated by semicolons. For example, one path name may be:
C:\WINNT\system32
There should be a path that looks like this: C:\j2sdk1.4.1_02\bin . This is a
directory called bin inside the directory where you installed the sdk . It may be
different on your computer. If such a path is not there, you have to add it. Bring
up the help in your Windows system, open the index, and look for "path". There,
you will find instructions on appending another directory to variable path. It
may be something like this (but read the instructions):
path %path%;C:\j2sdk1.4.1_02\bin
Summary
We have shown how to use JUnit to develop test cases that can be exercised
easily whenever a method is changed. What we have shown works very well for
testing individual methods. JUnit also provides the ability to create test suites
collections of tests that can be used to test the many classes that appear in a pro-
gram. A discussion of these other features is beyond the scope of this topic.
I.3
Using a command-line window
We describe how to deal with Java from an MDOS window on a PC. Dealing
with Java in a UNIX terminal window is similar.
In the window, navigate to the folder that contains the Java program that you
want to compile and execute. Suppose the Java program is a Java application
(see Sec. 16.1), and suppose that method main is in class ClassName .
Compiling the Java source files
To compile all the .java source files, type the following ( *.java expands
into a list of file names that end in .java ). This compiles your program —it is
equivalent to clicking button Compile all in DrJava.
javac *.java
Executing the program
To execute the program by calling static method main in class ClassName ,
type the command:
java ClassName
Note that the command should not include the suffix .class or .java .
Search WWH ::




Custom Search