Java Reference
In-Depth Information
LISTING 1.2
The Full Text of VolcanoApplication.java
1: class VolcanoApplication {
2: public static void main(String[] arguments) {
3: VolcanoRobot dante = new VolcanoRobot();
4: dante.status = “exploring”;
5: dante.speed = 2;
6: dante.temperature = 510;
7:
8: dante.showAttributes();
9: System.out.println(“Increasing speed to 3.”);
10: dante.speed = 3;
11: dante.showAttributes();
12: System.out.println(“Changing temperature to 670.”);
13: dante.temperature = 670;
14: dante.showAttributes();
15: System.out.println(“Checking the temperature.”);
16: dante.checkTemperature();
17: dante.showAttributes();
18: }
19: }
Save the file as VolcanoApplication.java and compile the program.
If you are using the JDK, you can do the following to compile the program: Go to a
command line or open a command-line window, open the folder where
VolcanoApplication.java is saved, and then compile the program by typing the follow-
ing at the command line:
javac VolcanoApplication.java
The Java compiler creates VolcanoApplication.class , a file containing bytecode
that can be executed by a Java interpreter. The compiler does the same for the
VolcanoRobot.java class if necessary because that class is being used in this application.
TIP
If you encounter problems compiling or running any program in
this topic with the JDK, you can find a copy of the source file
and other related files on the topic's official website: http://www.
java21days.com.
After you have compiled the application, run the program.
Using the JDK, you can run the VolcanoApplication program by opening the folder contain-
ing the VolcanoRobot.class and VolcanoApplication.class files by using this command:
java VolcanoApplication
 
Search WWH ::




Custom Search