Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 03-May-2022 | - | ||||
OBTest.java | H A D | 08-May-2020 | 475 | 31 | 23 | |
README | H A D | 08-May-2020 | 1.6 KiB | 41 | 30 | |
openbabel-java.cpp | H A D | 08-May-2020 | 1.8 MiB | 18,174 | 17,953 |
README
1Open Babel for Java 2------------------- 3 4This directory contains a compiled Java jar file with SWIG-generated 5interface classes for using the Open Babel C++ library from Java or from any 6other language that runs on the JVM such as Jython or JRuby. 7 8The Open Babel wiki pages on Java give information on compiling and 9running Java programs with Open Babel: 10http://openbabel.org/wiki/Java 11 12*** Linux Compilation 13 14 First of all, set some environment variables (remember to change the paths to correspond to your system): 15$ export JAVA_HOME=/home/noel/Tools/jdk1.5.0_15 16$ export OB_JAVADIR=/home/noel/Tools/openbabel-3.0.0/scripts/java 17$ export OB_LIBDIR=/home/noel/tree/lib # The install location of libopenbabel.so 18 19 Next, compile the Java bindings: 20$ cd $OB_JAVADIR 21$ g++ -c -fpic openbabel_java.cpp -I../../include -I$JAVA_HOME/include -I$JAVA_HOME/include/linux 22$ g++ -shared openbabel_java.o -L../../src/.libs -lopenbabel -o libopenbabel_java.so 23 24 Compile and run the test program: 25$ export CLASSPATH=.:$OB_JAVADIR/openbabel.jar 26$ $JAVA_HOME/bin/javac OBTest.java 27$ export LD_LIBRARY_PATH=$OB_JAVADIR:$OB_LIBDIR 28$ $JAVA_HOME/bin/java OBTest 29 30 If you get the output "Benzene has 0 atoms", you need to preload the OpenBabel library as follows: 31$ LD_PRELOAD=$OB_LIBDIR/libopenbabel.so $JAVA_HOME/bin/java OBTest 32 33*** Mac OS X Compilation 34 35As for Linux, but use the following instructions to compile the bindings. Also, replace LD_LIBRARY_PATH with DYLD_LIBRARY_PATH. 36 37% g++ -c -I/System/Library/Frameworks/JavaVM.framework/Headers \ 38openbabel_java.cpp 39% g++ -dynamiclib -o libopenbabel.jnilib openbabel_java.o \ 40-framework JavaVM -L/usr/local/lib -lopenbabel 41