The best way to avoid CLASSPATH issues is to use ant for both compiling and running your program. The SAADA_DB_HOME/bin/build.xml can be used as template.
Copy SAADA_DB_HOME/bin/saadadb.properties in your project directory (let’s say PROJECT_DIR)
Edit your build file : e.g. PROJECT_DIR/build.xml with something like that
<project name="MyProject" default="MyProgram.run">
<property file="saadadb.properties"/>
<property name="jvm_initial_size" value="-Xms64m" />
<property name="jvm_max_size" value="-Xmx1024m" />
<!--
This classpath is used by all java calls.
Classes or jar files specifiv for an application must be added here
-->
<path id="saadadb.classpath">
<pathelement location="${SAADA_DB_HOME}/algo_correlation/"/>
<fileset dir="${SAADA_DB_HOME}/lib/axis-1_2_1/">
<include name="**/*.jar" />
</fileset>
<fileset dir="${SAADA_DB_HOME}/lib/">
<include name="**/*.jar" />
</fileset>
<pathelement location="${SAADA_DB_HOME}/class_mapping/"/>
<pathelement location="${J2EE_HOME}/lib/j2ee.jar" />
<pathelement location="./" />
<fileset dir="${JAVA_HOME}/lib/">
<include name="**/*.jar" />
</fileset>
<fileset dir="${SAADA_DB_HOME}/jtools/ant/lib/">
<include name="**/*.jar" />
</fileset>
<!-
Added to include you classes
-->
<pathelement location="./"/>
</path>
<!--
Task compiling your project
-->
<target name="MyProgram.compile">
<javac fork="true" executable="${SAADA_DB_JAVAC}" debug="on"
srcdir="." destdir=".">
<classpath refid="saadadb.classpath"/>
</javac>
</target>
<!--
Task running your project
-->
<target name="MyProgram.run" depends="MyProgram.compile">
<java jvm="${SAADA_DB_JAVA}" classname="MyClass"
fork="true">
<classpath refid="saadadb.classpath"/>
<jvmarg value="${jvm_initial_size}" />
<jvmarg value="${jvm_max_size}" />
<arg value="${SAADA_DB_NAME}"/>
</java>
</target>
Now you just have to type ant in PROJECT_DIR tu run your project. - Ant will execute the default task MyProgram.run which has a dependency with the compilation task MyProgram.compile.
In the above example, we suppose that the main class is MyClass and that MyClass.java is in PROJECT_DIR. last update 2008-10-30
|