Running JAS Programs in Batch Mode

Running JAS Programs in Batch Mode on Linux

Classpath

In order to run JAS-based Java classes in batch mode, e.g. without the GUI, the Java CLASSPATH needs to include a number of runtime libraries.

Set the environment variable JAS_HOME equal the location of JAS3. This directory will contain the lib and extensions directories.

export JAS3_HOME=/path/to/jas3

The following directories should be appended to the Java CLASSPATH.

  • ~/.JAS3/classes
  • ~/.JAS3/extensions
  • $JAS_HOME/extensions
  • $JAS_HOME/lib

If Java reports an error about not finding user classes when it runs, then likely one of the above was not added properly.

Finding JAR Files

On Unix systems, a command such as the following will find JAR files from the current directory
and build up the CLASSPATH incrementally:

for jar in `find $F -name "*.jar" -print`; do
  CLASSPATH=$CLASSPATH:$jar
done

Each line from the find command is added to the CLASSPATH.

This should be done for every directory containing jars that need to be included.

Run Command

The following line will run a program with the CLASSPATH from the environment.

java -cp $CLASSPATH [class]

The [class] needs to be replaced with the name of the class to run.

It must have a main method.

public static void main(String[] args) throws Exception
{
  System.out.println("Hello, world.");
}

If the above is placed in a file called "HelloWorld.java" and compiled in JAS3, then
it can be run from the commandline like this, presuming the CLASSPATH is setup correctly.

java -cp $CLASSPATH HelloWorld

For a HOWTO of running a JAS3 Example outside of JAS3, proceed to org.lcsim with Jython in Batch Mode

Running a Driver from the Command Line on Linux at SLAC

First set up the shared environment:

bash
source /nfs/slac/g/lcd/mc/prj/scripts/prj-env.sh # Setup shared environment.  Only need once per session.
source /nfs/slac/g/lcd/mc/prj/scripts/jas-batch.sh

Next you probably do not want the released version of GeomConverter and lcsim, so make the jar files
either with NetBeans or from the command line using maven. See Building org.lcsim software

For those in the habit of running Drivers inside of JAS, here is a convenient way to run the same job from the command line.

java -cp $CLASSPATH org.lcsim.contrib.Cassell.DriverLoop [numberOfEvents] [name.aida] [DriverName] [DataSet1] [DataSet2] ...

The MainLoop class takes care of setting numberOfEvents , the datasets, and writing out the
default AIDA file as name.aida

To then run in batch, the same command is preceded by

bsub -q [batchQueueName] -o [logFileName]
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.