This file assumes that you have already downloaded and installed TextPad, and used it to compile simple programs.
The easiest way to compile and run the Marine Biology Simulation program, copy
the compMBS.bat
and runMBS.bat
files (for "Compile
MBS" and "Run MBS") from the DOSandWindows
folder to the JavaMBS\Code
folder. If your system cannot find the javac and java commands (if they are
not in a folder in your PATH
environment variable), edit the two
batch files and fully specify where javac.exe and java.exe can be found. You
can then run compMBS
directly in a DOS or Command Prompt window
(you must move to the Code
directory first), or run it from within
Textpad by choosing Tools -> Run. (You can open a file in the Code
directory first to make sure you're in the right directory.) Type in
compMBSas the Command, and leave the Parameters and Initial folder fields blank. Click on OK. The command will compile all the Java source files in the current directory (
Code
). You can also compile the files individually (see below),
but then you need to keep track of which source files have been modified.
To run the Marine Biology Simulation program, choose Tools -> Run again, but this time type
runMBSas the Command and one of the following class names in the Parameters field:
MBSGUI program with full graphical user interface (from beginning of Chapter 1) SimpleMBSDemo1 simple demo program (end of Chapter 1) SimpleMBSDemo2 second demo program (end of Chapter 1)If you do not specify the target,
runMBS
will use MBSGUI
.
When you go to open an environment data file, the file chooser window should
come up in the Code
folder, where the program is running. You will
need to go up to the JavaMBS
folder and then down to the DataFiles
folder to find the initial configuration files.
For Chapter 3 (and later chapters), if you are using the Fish.java
file from the DynamicPopulation
folder rather than modifying the
file in the Code
folder (see FishModsForChap3.txt
in the Code
folder for more details), copy the compDPop.bat
file from the DOSandWindows
folder to the JavaMBS\Code
folder. Correct the full path name for the javac command as you did in compMBS.bat
(if necessary). Run compDPop
from the Code
folder.
(You can open a file in the Code
folder to make sure you're in
the right folder.) This command will compile the Fish
class in
the DynamicPopulation
folder and then copy the compiled class file
to the Code
folder. Then run the Marine Biology Simulation as usual.
To compile source files individually from within TextPad, you will first need to set your "classpath" to find the jar files containing the black box and graphical user interface classes.
One way to do this is to set the classpath within the TextPad preferences. Go to Configure -> Preferences and click on "Compile Java" under the Tools topic. The input field for Parameters: should say "$File". Modify this field so that it has
-classpath .;.\mbsbb.jar;.\mbsgui.jar $FileThen click on OK. You can modify the Parameters for "Run Java Application" by inserting the same classpath information before $BaseName. [Warning: The disadvantage of this technique is that you will now be using this classpath whenever you compile or run Java files within TextPad, at least until you change the preferences again. This should not create problems for you, though, unless you compile other programs that use the same class names as the MBS black box and GUI code.]
You can also set the CLASSPATH environment variable through AUTOEXEC.BAT or through the control panel. In either case, first check whether CLASSPATH is already defined.
- Yes: prepend .;.\mbsbb.jar;.\mbsgui.jar; - No: set it to .;.\mbsbb.jar;.\mbsgui.jar[Warning: The disadvantage of this technique is that you will now be using this classpath whenever you compile a Java file. This should not create problems for you, though, unless you compile other programs that use the same class names as the MBS black box and GUI code.]
Once you have set your classpath, you can compile individual Java source files using the Compile Java option in the Tools menu.