FAQ

Why do the methods in G4Java classes start with lowercase?
This is general Java coding style. Geant4 seems to use methods starting with lowercase and uppercase. To make sure you have the feeling you are programming in Java we renamed all methods to start with lowercase.
Why are public and protected fields not available using the talligent naming scheme (fSomeField)?
Fields in C++ classes can only be made available to Java by using methods. In Java hardly anybody uses the talligent naming scheme, so we took the liberty to rename fSomeField, pSomePointer and thePointer to getPointer(), etc, etc...
What happened to G4Colour, G4Color?
Java has its own java.awt.Color class, so it seemed unnatural to use G4Color.
What happened to G4double, G4int, etc?
G4double and other primitives were introduced because C++ does not have a strict requirement about the width of the different primitive types. This allows Geant4 to map them in a platform dependent way to the correct width. Java has strict specifications about the width of its primitives, so we use the standard Java primitives (int, double, long, ...)
G4String seems to have vanished as well?
Correct, Java has its own String class. It is converted when calling in and out of Geant4.
What about std::vector and other collection classes?
Where possible we translated C++ collection classes to Java collection classes.
Can I use G4Java in my favorite Java IDE?
Yes, by adding the G4Java.jar file to the classpath, your IDE will know about its classes and be able to "link" against it and do things like code completion. API documentation lookup could also work, except for now we have no access to the C++ documentation in Java.
Does G4Java make Geant4 architecture independent?
Partially. The application code in Java is of course system independent, as is the Geant4 Java wrapper code generated by SWIG. However, SWIG also generates C++ wrapper code, which links with the standard Geant4 C++ libraries (and CLHEP) to create an architecture dependent Geant4 shareable library. For the standard three operating systems (Windows, MacOSX and Linux) these libraries are provided.
Can I create the Geant4 shareable library myself, and do I need SWIG for that?
Yes, you can create the shareable library yourself by using the source code and compiling and linking it with geant4. You first need to create the geant4 global libraries. You can then use our sources (generated by SWIG) to create the shared library. There is no need to recreate the geant4 java jar file.
What about G4Java's performance?
Calls from Java into C++ are relatively fast. The problem is/may be the callbacks from C++ into Java. This happens for instance to calculate the magnetic field in a point. If the MagneticField class is implemented in Java, Geant4 will call into Java many times. For now, we have not optimized this in any way.