G4Java Examples

This is normally the ONLY step a user would have to follow to write some Geant4 Java code and compile/run it with G4Java. If however your platform is different than the ones mentioned, or want to use a specific c++ compiler, you may have to rebuild clhep, geant4, swig and G4Java.

Get the code and build

To download the G4Java Examples type

svn co svn://svn.freehep.org/svn/sandbox/G4Java-examples

and compile them by running maven

mvn

This may take quite some time the first time as the correct G4Java shareable library needs to be downloaded and unpacked.

Running the examples

To run any of the examples, source or run the setup script

setup.bat

   or

source setup.sh

and launch an example by typing for instance:

ExampleN01.bat

   or

ExampleN01.sh

Your own Java code and G4Java

To compile and run your own Java code with G4Java you can use our maven setup and copy the pom.xml file from G4Java-examples, or you can just put G4Java-VERSION.jar on the CLASSPATH and compile your code. To run your code you need to make sure G4Java-VERSION.so or G4Java-VERSION.dll can be found by setting LD_LIBRARY_PATH, DYLD_LIBRARY_PATH or PATH.