

- STATCALC JAVA SYSTEM OUTPUTLN HOW TO
- STATCALC JAVA SYSTEM OUTPUTLN CODE
- STATCALC JAVA SYSTEM OUTPUTLN SIMULATOR
Note that I assumed in the above that the simulator for robot programs is called KarelJRobot.jar, which is true when this is written. In the java command, however, you always name just one class, the one that contains the main that you want to execute. Just include a list of filenames in the javac instruction separated by spaces. You can do this all at once just by including them all where we have shown GetBeeper.java. In the next chapter we will see that it is possible to have many files to compile. In particular you need the -classpath option followed by what is shown above as well as the -d option followed by a space and a period in the compile instruction. This latter instruction tells java to look in the kareltherobot directory for the file GetBeeper.class and execute the main that it finds there.Īll of the above is needed and must appear just about as shown.

You may be able to abbreviate classpath in the above with cp instead. Once you have done the above, you can execute your program with the "Java Virtual Machine", java. If there are no errors in your program then (for robot programs) a new directory will be created called kareltherobot and it will contain the machine readable versions of your program in one or more "class" files. This command is typed into a command window on your computer. On a unix system (including Macintosh OS X) the semicolon would be replaced by a colon. This assumes you are working in a Windows environment and have established a working directory with all of your files. A command to do this would be something like javac -d. The build step is then carried out by the "Java compiler" called javac. You create your robot programs with a text editor and make sure that the file names end in ".java". However, if you do not have an environment to work with then you need to use the JDK (Java Development Kit) from Sun Microsystems. Then it is just a matter of pushing buttons or selecting menu options to build and execute.
STATCALC JAVA SYSTEM OUTPUTLN CODE
This will include any code you write as well as the robot simulator code that you can get from the authors. If you have a Java environment like Eclipse or JBuilder, you create a "project" in the environment and add your files to it. First you must "build" your program and then "execute" it. Once you have a complete Robot program (or any Java program) you will want to execute it to see its effect. Either will serve, though the latter is a bit easier to use. In the book we often speak of the "main task block." You can interpret this to either mean a static main method as in the first example above, in which your class implements Directions, or as a task method in some class that implements RobotTask. Note that task here is NOT a static method.
STATCALC JAVA SYSTEM OUTPUTLN HOW TO
Your class needs to implement RobotTask so that the other class, RobotRunner knows how to interpret this and run the task method here. The following is what must appear in a real Java program.

In Java, you need to have a method named main in at least one class. The Java Main Method The Java Main Method
