By: Hoang Huynh ([email protected]) Copyright ...peter.liu/jac444/jfreechart.pdf · 1....
Transcript of By: Hoang Huynh ([email protected]) Copyright ...peter.liu/jac444/jfreechart.pdf · 1....
We will be using two JAR files from the JFreeChart library:1. C:\Program Files\jfreechart-1.0.9\lib\jcommon-1.0.12.jar2. C:\Program Files\jfreechart-1.0.9\lib\jfreechart-1.0.9.jar
2
3
1. Open up the Robocode workspace in Eclipse2. Open up the “robocodeextract” project and copy the
jfreechart-1.0.9.jar and jcommon-1.0.12.jar files to robocodeextract’s libs folder
4
5
Now, we will add a reference to the JAR files from the robocodeproject.
Right click on the “robocode” project folder and click “Properties”
6
Select “Java Build Path”, then open the “Libraries” tab. Then click the “Add JARs…” button.
7
11
Open up the ANT build script (the build.xml file in the build project) and browse to the “compile.robocode” target.
Now, modify the “<!-- Copy libs into the build folder -->” section to read:
<!-- Copy libs into the build folder -->
<copy file="${src.extract}/libs/codesize.jar" toDir="${build}/libs"/>
<copy file="${src.extract}/libs/jcommon-1.0.12.jar" toDir="${build}/libs"/>
<copy file="${src.extract}/libs/jfreechart-1.0.9.jar" toDir="${build}/libs"/>
And the “<!-- Compile Robocode -->” section to read:<compile srcdir="${src.robocode}" destdir="${build}"
classpath="${build}/libs/codesize.jar;${build}/libs/jcommon-
1.0.12.jar;${build}/libs/jfreechart-1.0.9.jar"/>
Result:Robocode will now automatically copy the JAR files to the build folder, and reference it when compiling.
12
Save the file.
You should now be able to compile, but you will get a runtime error when you attempt to run Robocode from Eclipse.
13
14
Setting up the class path.
Click on the Run button and click “Open Run Dialog…”
15
Browse to the Robocode run configuration, open the Classpathtab, click the on the “User Entries” tree node, and then click “Add JARs…”
16
Select the two JFreeChart JAR files in the build/build/lib folder. Click OK
Note - If you don’t see the build folder or the JAR files, you need to:
• Recompile your Robocode project (by clicking on the Project menu > Clean…), and/or• Refresh the “build” project folder (by right clicking on the “build” project folder and clicking “Refresh”)
17
Apply the changes and test your project by clicking Run.
Result:You can now run Robocode in Eclipse, but you won’t be able to run it outside of Eclipse.
18
19
There are two minor changes we have to make if you want to deploy using the archive.setup build target.
First, open up the robocode.bat file using the Text Editor (do not double click it! That will run the file!)
20
Append this to the end of the –cp (classpath) command line option:
;libs/jfreechart-1.0.9.jar;libs/jcommon-1.0.12.jar
The file should now read as:java -Xmx512M -Dsun.io.useCanonCaches=false -cp
libs/robocode.jar;libs/codesize.jar;libs/cachecle
aner.jar;libs/jfreechart-1.0.9.jar;libs/jcommon-
1.0.12.jar robocode.Robocode
21
Now, do the same for “robocode.sh”
22
Append this to the end of the –cp command line argument::libs/jfreechart-1.0.9.jar:libs/jcommon-1.0.12.jar
So that the line reads as:java -Xmx512M -Dsun.io.useCanonCaches=false -cp
libs/robocode.jar:libs/codesize.jar:libs/cachecle
aner.jar:libs/jfreechart-1.0.9.jar:libs/jcommon-
1.0.12.jar robocode.Robocode $*
23
Save the files, and you’re done! If you need additional help, feel free to contact me at: [email protected]
24