| Log In | Not a Member? |
Contact ADC
|
|
![]() |
|
|
| Previous Section | Table of Contents | Next Section |
Setting Up and Building
the Project
|
This tutorial is designed to be used with any Java development environment. As a result, it is assumed that you are familiar with the development environment that you will be using to complete this tutorial. For each of these modules, there are some common steps that you will have to perform in order to successfully build your project. These steps are broken down by platform for your convenience. MacintoshIn order to build and run each module on the Macintosh, there are a series of steps that are required to compile, link, and build a double-clickable application. The steps shown below use the standard JDK tools that are part of the MRJ SDK 2.2. The steps for your individual development environment may vary.Compiling the Source After writing the code for each module in your editor of choice, you will need to compile the code to produce class files for each source. This is accomplished with the javac tool in MRJ SDK 2.2:Tools:JDK Tools. For ease of use, we have created a folder called Source in each module. This is where we save the source files. We also have a folder called Output where all the compiled classes are to be placed. In order to compile the code, select each of the Java source files in the Finder and drop them on the javac tool. This will automatically add these files to the Source Files list in the Javac window (see image below).
This example illustrates the required settings for module 5. You may also add and remove files individually using the add and remove buttons. Once the source files are specified, you may specify the destination directory by clicking the Select button and navigating to the output directory. Finally, you will need to add QTJava.zip to the classpath. Click on the Add button next to the Classpath file list and navigate to the MRJClasses folder (in the MRJ Libraries folder in the Extensions folder of the System). Once all your settings are complete, click on the Do Javac button to generate the classfiles in the output directory. Creating a Jar File Once we have created all of class files for the project,
we need to create a Jar File. This archive file contains all of our compiled
code. Once we made a copy of the application, select all of the class files in the output directory and drop them on the jar tool. These files should show up in the Input Files and Directories list. Make sure that the Create Archive entry in the function popup at the top of the window is the selected item. Type the name of the jar file that you want to create in the Destination File edit text field. We recommend that you use the same name for your jar file as your main class with a .jar extension. Once you have finished specifying these options, click on the Do Jar button. The image at the left shows the Jar settings for Module 5. Once you are finished with the Jar tool, delete the copy of the application from your output folder. We also recommend that you move the jar file out of the output directory into the same folder that contains your source and output directories. Building a Double-Clickable Application As part of the download for each module, there is a properties file that is used to build a double-clickable application using the MRJ App Builder. The properties file has the same name as the main class of the module with a .properties extension. For example, the property file for module 5 is named Zoo5.properties. NOTE: The MRJ App Builder is new with the MRJ 2.2 SDK. If you are using an older version of the SDK, you will need to use JBindery to make your double-clickable application. Follow the instructions that come with JBindery instead of these steps.
The configuration file location should be already filed in. If it is not, click the Select button and navigate to the Properties file associated with the module you are building. The appropriate jar file should also be filled in. Specifying the jar file here will automatically merge the jar file into the application. This means that the jar file is not externally referenced and all of the code required to run your application is in a single executable file. Once you have specified the correct settings, click the Build button to make your double-clickable application. Setting the Default Application Partition
To do this, we need to select the application in the Finder and choose Get Info > Memory from the File menu. In this window (shown at left) there are two editable boxes: Minimum Size and Preferred Size. By default, the Minimum size is 512 K and the Preferred Size is 1024. It is a good idea to increase both of these sizes. You should set the Minimum Size to 2048 and the Preferred size to something like 2524. This will increase the memory partition of the application so that QuickTime has enough application heap space for the images, sound, and other resources needed by your application. Once you have completed these steps, you can launch your application by double-clicking the icon. Windows In order to build and run each project under Windows NT, Windows 95 or Windows 98, there are a series of steps that are required to compile, link and build a double-clickable application. The steps shown below use the standard tools that are part of Sun's JDK. Before we compile the source, it is important to make sure that QuickTime for Java is on the class path. You can determine this by typing set at a DOS prompt. You should see something like: CLASSPATH=C:\jdk1.2.2\jre\lib\ext\QTJava.zip;C:\JDK1.1.8\lib\classes.zip; If you do not have the correct path, QuickTime for Java will not function correctly. For information on setting the classpath environment variable, consult the Sun Java Documentation. Compiling the Source In order to compile the source on windows, you will use the javac command-line tool. Navigate to the directory where your source is located and then type the following: javac -d c:\Zoo\Module5\Output; *.java You may find it necessary to reference your classpath explicitly: javac -classpath %CLASSPATH%;c:\jdk1.1.2\jre\lib\ext\QTJava.zip;C:\Zoo\Module5\Source; *Java -d c:\Zoo\Module5\Output; If you are having difficulty using the javac tool, please consult Sun's javac documentation. Creating a Jar File To create a Jar File, we use the jar tool: jar cvf zoo5.jar Output/ If you are having difficulty using the jar tool, please consult Sun's jar documentation. Running the Application To run the application in windows, we use the Java tool from the command line: Java -classpath %Classpath%;Zoo5.jar Zoo5 You may find it more convenient to make a batch file for each module so that you can run the application by double-clicking on the batch file. In order to do this, create a new file in NotePad (or any other text editor such as WordPad) and save the command line to a file. For example, you could save the above command line statement to a file called Zoo5.bat. When you clicked on this batch file, the application would automatically run. For additional documentation on the Java command line tool, consult Sun's Java documentation. |
| Previous Section | Table of Contents | Next Section |