Java on a mac (OS X 10.3.5), continued from last post (with lj cuts)
Does anyone know what kind of java is on a mac (I've been asked, and don't know)?
(eg sun's java, ibm's java, ...)
In this post, I am including instructions for setting up java in order to be able to run things on our own computers as well as remotely on school's computers. But they are instructions for Windows users, and I am a mac user. So the question is, what do I need to do with the line in the build.xml file that says:
property name="java.runtime" value="${java.home}/jre/lib/rt.jar"/
For windows users, here are the instructions for downloading java:
1. Go to http://java.sun.com/j2se/downloads/index.html
2. Download the latest version of the Java 2 Standard Edition (J2SE) SDK (currently J2SE 1.4.2)
3. Run the downloaded file to install java
4. When the installation prompts for what components to install, click the "Change" button and
change the installation directory to: C:\j2sdk1.4.2
Then, what they have under /appl/j2sdk1.4.2 which is:
[use@name user]$ dir /appl/j2sdk1.4.2/
total 11364
drwxr-xr-x 2 root root 4096 Sep 17 2003 bin
-r--r--r-- 1 root root 4431 Sep 16 2003 COPYRIGHT
drwxr-xr-x 6 root root 4096 Sep 17 2003 demo
drwxr-xr-x 3 root root 4096 Sep 17 2003 include
drwxr-xr-x 6 root root 4096 Sep 17 2003 jre
drwxr-xr-x 2 root root 4096 Nov 26 2003 lib
-r--r--r-- 1 root root 18864 Sep 16 2003 LICENSE
drwxr-xr-x 4 root root 4096 Sep 17 2003 man
-r--r--r-- 1 root root 8986 Sep 16 2003 README
-r--r--r-- 1 root root 16251 Sep 16 2003 README.html
-rw-r--r-- 1 root root 11523825 Sep 16 2003 src.zip
-r--r--r-- 1 root root 10129 Sep 16 2003 THIRDPARTYLICENSEREADME.txt
And then they are told to do this:
How to setup Windows Environment Variables for Java
1. Go to the Windows Control Panel (Start->Settings->Control Panel OR Start->Control Panel)
2. Double click "System"
NOTE: In Windows XP, if you do not see "System" you might need to click "Switch to Classic View" first.
3. Click the "Advanced" tab
4. Click the "Environment Variables" button
5. Click "New" to add a variable
6. For "Variable Name" put:
JAVA_HOME
7. For "Variable Value" put:
C:\j2sdk1.4.2
8. Click the OK button
9. Find the variable "PATH" and click the "Edit" button
10. Add this to the end of the string for "Variable Value":
C:\j2sdk1.4.2\bin;C:\appl\ant1.6.2\bin
11. Click the OK button until you get back to the control panel
12. Close the control pane
So that in the end they can refer to this simple name in build.xml
Here is the build.xml code. NOTE: It's xml code, and to post here, I've replace ">" with ")" etc.
Here is where I need to know JAVADIR:
#!/bin/sh
# simple wrapper script to do batch runs ...e.g.,
# /appl/repast/UM/Template2/bin/batchrun.s h nA=100 T=400
# this is primarily intended to use be used as the programName in
# drone control files. See
# /appl/repast/UM/Template2/Readme.txt
#
# the parameters below will most likely need to be changed
# model specific things
PROJECTDIR=/users/khassmil/basicUntreate d/
PACKAGENAME=basicUntreated
BATCHMODELNAME=BatchModel
# add extra user libraries that should be included here
USERDEFINEDLIBS=
# the params below should be changed when versions of java
# and different libraries are upgraded so they point to the
# correct paths of java and libraries
# java path
JAVADIR=/appl/j2sdk3d1.4.2_04
# library paths
REPASTLIBDIR=/appl/repast/repast2.2/lib
CSCSLIBDIR=/appl/java/CSCS
VISADLIBDIR=/appl/java/visad2.0
# XERCESDIR=/appl/xerces-2.4.0
COMMONSDIR=/appl/java/commons-collection s-2.1
JUNGDIR=/appl/java/jung1.1.1
# the actual run command
$JAVADIR/bin/java -cp $USERDEFINEDLIBS:$PROJECTDIR/classes:$RE PASTLIBDIR/repast.jar:$REPASTLIBDIR/colt.j ar:$REPASTLIBDIR/jgl3.1.0.jar:$REPASTLIB DIR/plot.jar:$REPASTLIBDIR/trove.jar:$CS CSLIBDIR/graph3d.jar:$CSCSLIBDIR/ioutils.j ar:$CSCSLIBDIR/hbbeta2-printf.jar:$VISAD LIBDIR/visad.jar:$COMMONSDIR/commons-col lections.jar:$JUNGDIR/jung-1.1.1.jar $PACKAGENAME.$BATCHMODELNAME $*
(eg sun's java, ibm's java, ...)
In this post, I am including instructions for setting up java in order to be able to run things on our own computers as well as remotely on school's computers. But they are instructions for Windows users, and I am a mac user. So the question is, what do I need to do with the line in the build.xml file that says:
property name="java.runtime" value="${java.home}/jre/lib/rt.jar"/
For windows users, here are the instructions for downloading java:
1. Go to http://java.sun.com/j2se/downloads/index.html
2. Download the latest version of the Java 2 Standard Edition (J2SE) SDK (currently J2SE 1.4.2)
3. Run the downloaded file to install java
4. When the installation prompts for what components to install, click the "Change" button and
change the installation directory to: C:\j2sdk1.4.2
Then, what they have under /appl/j2sdk1.4.2 which is:
[use@name user]$ dir /appl/j2sdk1.4.2/
total 11364
drwxr-xr-x 2 root root 4096 Sep 17 2003 bin
-r--r--r-- 1 root root 4431 Sep 16 2003 COPYRIGHT
drwxr-xr-x 6 root root 4096 Sep 17 2003 demo
drwxr-xr-x 3 root root 4096 Sep 17 2003 include
drwxr-xr-x 6 root root 4096 Sep 17 2003 jre
drwxr-xr-x 2 root root 4096 Nov 26 2003 lib
-r--r--r-- 1 root root 18864 Sep 16 2003 LICENSE
drwxr-xr-x 4 root root 4096 Sep 17 2003 man
-r--r--r-- 1 root root 8986 Sep 16 2003 README
-r--r--r-- 1 root root 16251 Sep 16 2003 README.html
-rw-r--r-- 1 root root 11523825 Sep 16 2003 src.zip
-r--r--r-- 1 root root 10129 Sep 16 2003 THIRDPARTYLICENSEREADME.txt
And then they are told to do this:
How to setup Windows Environment Variables for Java
1. Go to the Windows Control Panel (Start->Settings->Control Panel OR Start->Control Panel)
2. Double click "System"
NOTE: In Windows XP, if you do not see "System" you might need to click "Switch to Classic View" first.
3. Click the "Advanced" tab
4. Click the "Environment Variables" button
5. Click "New" to add a variable
6. For "Variable Name" put:
JAVA_HOME
7. For "Variable Value" put:
C:\j2sdk1.4.2
8. Click the OK button
9. Find the variable "PATH" and click the "Edit" button
10. Add this to the end of the string for "Variable Value":
C:\j2sdk1.4.2\bin;C:\appl\ant1.6.2\bin
11. Click the OK button until you get back to the control panel
12. Close the control pane
So that in the end they can refer to this simple name in build.xml
Here is the build.xml code. NOTE: It's xml code, and to post here, I've replace ">" with ")" etc.
(?xml version="1.0"?)
(project name="basicUntreated" default="all" basedir=".")
(!-- Tell ant the compiler is Java 1.4 --)
(property name="build.compiler" value="modern"/)
(!-- Set the projectName --)
(property name="projectName" value="basicUntreated"/)
(property name="debugFile" value="debug.out"/)
(property name="isDistFile" value=".isdist"/)
(!-- properties that should be overrided on the command line --)
(!-- if you are going to use the "verynew" option --)
(property name="ROOTDIR" value=".."/)
(property name="NAME" value="NONAME"/)
(property name="args" value=""/)
(!-- Set up dirs:
classDir is the directory the compiled code goes to
srcDir is the directory with the code in it
libDir is the directory with the libraries
libDir is only used with the distribution version
distDir is the dir that the distribution version is
created in --)
(property name="binDir" value="bin"/)
(property name="classDir" value="classes"/)
(property name="srcDir" value="src"/)
(property name="libDir" value="lib"/)
(property name="distDir" value="dist"/)
(property name="saveDir" value="Saves"/)
(!-- This stuff tells where libraries are. --)
(property name="java.runtime" value="${java.home}/jre/lib/rt.jar"/)
(property name="repastDir" value="/appl/repast/repast2.0"/)
(property name="cscslibDir" value="/appl/java/CSCS"/)
(property name="visadDir" value="/appl/java/visad2.0"/)
(property name="xercesDir" value="/appl/xerces-2.4.0"/)
(fileset id="repast.jars" dir="${repastDir}/lib")
(include name="repast.jar"/)
(include name="colt.jar"/)
(include name="jgl3.1.0.jar"/)
(include name="plot.jar"/)
(include name="trove.jar"/)
(/fileset)
(fileset id="cscs.jars" dir="${cscslibDir}")
(include name="graph3d.jar"/)
(include name="ioutils.jar"/)
(include name="hbbeta2-printf.jar"/)
(/fileset)
(fileset id="visad.jars" dir="${visadDir}")
(include name="visad.jar"/)
(/fileset)
(fileset id="xerces.jars" dir="${xercesDir}")
(include name="xercesImpl.jar"/)
(/fileset)
(path id="classpath")
(!-- MsM (fileset refid="repastbeta.jars"/)--)
(pathelement location="${classDir}"/)
(fileset refid="repast.jars"/)
(fileset refid="cscs.jars"/)
(fileset refid="visad.jars"/)
(fileset refid="xerces.jars"/)
(/path)
(property name="classpath.string" refid="classpath"/)
(target name="help"
depends="getDate,getTime")
(echo)
---------
ANT TASKS
---------
all creates the "${classDir}" directory, compiles the code,
and puts the compiled classes into the "${classDir}"
directory.
batchrun run the program in batch mode. arguments can be passed
to the batch run by doing:
ant batchrun -Dargs="your arguments here"
see below about setting arguments on the command line
clean deletes the directory "${classDir}"
compile compiles the project and puts the compiled classes in
"${classDir}"
debug run the project in debug mode, piping the output to ${debugFile}
distjar creates a distribution jarfile in "${distDir}/${projectName}.jar"
parsereport parses an XML report file given by the F argument.
for example, to parse the report file "report.xml.00" do:
ant parsereport -Dargs="report.xml.00"
prepare prepares the project to be compiled (creates the
"${classDir}" directory)
projecthelp shows the help that is printed in the project
realclean deletes "${classDir}", "${libDir}", "${distDir}", and the debug
and report files
run run the program in GUI mode. you can pass arguments to the
model by doing:
ant run -Dargs="your arguments here"
see below about setting arguments on the command line
save create a jarfile with the contents of the current directory
and store it in:
"${saveDir}/projectName-today'sdate-timerightnow.jar"
for example, if one were created right now it would have
the name:
"${saveDir}/${projectName}-${today}-${timenow}.jar"
-------------------
OPTIONAL PARAMETERS
-------------------
Here is the list of buildfile parameters that can be changed:
NAME DESCRIPTION
----------------------------------------------------------------------
debugFile the debug file name
args a listing of the arguments to send to the java program
example:
ant run -Dargs="iPFN=dat/parameters1.xml nA=100"
debugFile and args could be used with any of the run commands
To set any of the above parameters do -DNAMEOFARGUMENT="value"
For example,
ant run -Dargs="iPFN=dat/parameters1.xml nA=100"
(/echo)
(/target)
(!-- This is the default target. The default is to
compile the project. --)
(target name="all"
description="creates the ${classDir} directory, compiles the code, and puts the compiled classes into the ${classDir} directory"
depends="prepare, compile"/)
(!-- Set up the directory the code will compile into --)
(target name="prepare" description="prepares the project to be compiled (creates the ${classDir} directory)")
(mkdir dir="${classDir}"/)
(/target)
(!-- Compile the code --)
(target name="compile"
description="compiles the project and puts the compiled classes in ${classDir}"
depends="prepare")
(!-- Check to see if any one of the source files or build.xml were
changed. If any of them have a time stamp newer than the
newest *.class file, then delete all of the *.class files
This makes it so whenever you change anything, ant will
recompile the entire project --)
(dependset)
(srcfileset dir="${srcDir}" includes="**/*.java"/)
(srcfileset dir="." includes="build.xml"/)
(targetfileset dir="${classDir}" includes="**/*.class"/)
(/dependset)
(!-- Compile the code in srcDir and put it in classDir.
If srcDir does not have the same directory structure
as classDir, then the code will always compile itself --)
(javac destdir="${classDir}"
srcdir="${srcDir}")
(classpath refid="classpath"/)
(/javac)
(/target)
(!-- Run the project. If you run it through ant, you must
tell it to fork (fork="true") or it will exit after
only a few seconds. --)
(target name="run"
description="run the project and send output to screen"
depends="compile")
(java classname="${projectName}.GUIModel"
fork="true")
(classpath refid="classpath"/)
(arg line="${args}"/)
(/java)
(/target)
(target name="debug"
description="run the project in GUI mode and pipe the output to ${debugFile}"
depends="compile")
(echo message="*** debug mode: Piping debug output to ${debugFile} ***"/)
(java classname="${projectName}.GUIModel"
fork="true"
output="${debugFile}")
(classpath refid="classpath"/)
(arg line="${args}"/)
(/java)
(/target)
(target name="batchrun"
depends="compile"
description="run the project in batch mode")
(java classname="${projectName}.BatchModel"
fork="true")
(classpath refid="classpath"/)
(arg line="${args}"/)
(/java)
(/target)
(target name="projecthelp"
description="shows the help that is printed in the project"
depends="compile")
(java classname="${projectName}.GUIModel"
fork="true")
(classpath refid="classpath"/)
(arg line="--help"/)
(/java)
(/target)
(target name="clean"
description="deletes the directory ${classDir}")
(delete dir="${classDir}"/)
(/target)
(target name="realclean"
description="deletes ${classDir}, ${libDir}, ${distDir}, and the debug and report files")
(delete dir="${classDir}"/)
(delete dir="${libDir}"/)
(delete dir="${distDir}"/)
(delete file="${debugFile}"/)
(delete file="report.00"/)
(/target)
(target name="save"
depends="getDate, getTime"
description="create a save jar in ${saveDir}/${projectName}-${today}-${timenow}.jar")
(jar jarfile="${saveDir}/${projectName}-${today}-${timenow}.jar"
basedir="."
includes="${srcDir}/**, dat/**, *.txt, build.xml"/)
(echo message="The jarfile is in ${saveDir}/${projectName}-${today}-${timenow}.jar"/)
(/target)
(target name="getDate")
(!-- This sets the variable ${today} to today's date in
the format:
(last 2 numbers of year)(2 digit month)(2 digit day) --)
(tstamp)
(format property="today"
pattern="yyMMdd"/)
(/tstamp)
(/target)
(target name="getTime")
(!-- This sets the variable ${timenow} to the time
in the format:
(2 digit hour)(2 digit time) --)
(tstamp)
(format property="timenow"
pattern="HHmm"/)
(/tstamp)
(/target)
(target name="parsereport"
description="parse a report file given by the args argument"
depends="compile")
(java classname="mcharter.parseReport"
fork="true")
(classpath refid="classpath"/)
(arg line="${args}"/)
(/java)
(/target)
(/project)
Here is where I need to know JAVADIR:
#!/bin/sh
# simple wrapper script to do batch runs ...e.g.,
# /appl/repast/UM/Template2/bin/batchrun.s
# this is primarily intended to use be used as the programName in
# drone control files. See
# /appl/repast/UM/Template2/Readme.txt
#
# the parameters below will most likely need to be changed
# model specific things
PROJECTDIR=/users/khassmil/basicUntreate
PACKAGENAME=basicUntreated
BATCHMODELNAME=BatchModel
# add extra user libraries that should be included here
USERDEFINEDLIBS=
# the params below should be changed when versions of java
# and different libraries are upgraded so they point to the
# correct paths of java and libraries
# java path
JAVADIR=/appl/j2sdk3d1.4.2_04
# library paths
REPASTLIBDIR=/appl/repast/repast2.2/lib
CSCSLIBDIR=/appl/java/CSCS
VISADLIBDIR=/appl/java/visad2.0
# XERCESDIR=/appl/xerces-2.4.0
COMMONSDIR=/appl/java/commons-collection
JUNGDIR=/appl/java/jung1.1.1
# the actual run command
$JAVADIR/bin/java -cp $USERDEFINEDLIBS:$PROJECTDIR/classes:$RE
