Creating a custom oejava jar file¶
In the previous examples, we used the entire oejava-*-.jar JAR file for the projects. In most cases, this is the easiest path since it contains all the toolkits for a particular platform.
But there are times where it may be desired to create a smaller, custom JAR containing only the specific toolkits for that project. Additionally, for a project that needs to run on several different platforms, we can also merge in two or more platforms, making a single JAR.
In the same directory that contains the oejava-*-.jar file(s), you’ll find another jar that contains a small program for generating these custom JARs. The next section shows some example uses of this program.
Examples of creating a special jar¶
If you run the program with no command line arguments, you’ll see the basic syntax of the command as well as a list of available toolkits to include.
$ java -jar openeye-javautils.jar
usage: Main -products <prod list> -jars <jar list> -out <new jar name>
Available Products:
OEBio
OEChem
OEDepict
OEDocking
OEGraphSim
OEGrapheme
OEIUPAC
OEMedChem
OEMolProp
OEOmega
OEQuacpac
OEShape
OESpicoli
OESzmap
OESzybki
OEZap
The simplest example is to create a smaller JAR, containing a subset of the toolkits. Assuming we are working on 32-bit Windows, and want to create a new JAR with only OEChem and OEGraphSim, we would do something like:
$ java -jar openeye-javautils.jar -products OEChem OEGraphSim \
-jars oejava-v1.8.0-Windows-x86.jar -out oechem-special-win32.jar
You can then use this new JAR for your new project. You’ll note that it is significantly smaller, but still self-contained to support a project using OEChem and OEGraphSim only.
A potentially more useful feature is the ability to merge multiple platforms into one new JAR, allowing cross-platform project and cross-platform FAT JARs.
A standard scenario might be where you develop on Windows (using 32-bit Java) but want to deploy on 64-bit Linux. First gather the original JARs for the two platforms of interest.
$ ls oejava*
oejava-v1.8.0-Linux-x64.jar oejava-v1.8.0-Windows-x86.jar
Then run the program to create a new JAR with OEChem, OEDepict and OEGrapheme.
$ java -jar openeye-javautils.jar -products OEChem OEDepict OEGrapheme \
-jars oejava-v1.8.0-Windows-x86.jar oejava-v1.8.0-Linux-x64.jar \
-out oechem-oedepict-oegrapheme-Win32-Linux64.jar
Using this new JAR in your project in Eclipse will allow you to create a FAT JAR that will run on both Win32 and Linux64.