Here is the simple code I wrote to test loading the library:

public static void runOpenBabel() {
   logger.info(System.getProperty("java.library.path"));
   try {
      //System.load("~/Applications/openbabel/lib/libopenbabel_java.jnilib");
      System.loadLibrary("openbabel_java");
      logger.debug("Successfully loaded the openbabel lib");
   } catch(UnsatisfiedLinkError e) {
      logger.fatal("cannot load jni lib");
   }
}

The path ends up being: ~Applications/openbabel/lib

What I do is I add to the java.library.path variable:
-Djava.library.path=/path/to/openbabel/lib/   => which translates to above

And the above code will throw the following error:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x0000000110c55761, pid=64236, tid=7171
#
# JRE version: Java(TM) SE Runtime Environment (8.0_60-b27) (build
1.8.0_60-b27)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.60-b23 mixed mode
bsd-amd64 compressed oops)
# Problematic frame:
# C  [libawt_lwawt.dylib+0x44761]  JNI_OnLoad+0x91
#
# Failed to write core dump. Core dumps have been disabled. To enable core
dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /Users/jason/Projects/IntelliJ/ChemTrails/hs_err_pid64236.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

Process finished with exit code 134

Upon running CMake, make, make install for openbabel there were no reported
errors.




On Thu, Oct 6, 2016 at 10:06 AM, Jason Ott <jott...@ucr.edu> wrote:

> MacOS Sierra 10.12 (16A323) with 2.4.0 of OpenBabel and Java 1.8.0_60
>
> On Wed, Oct 5, 2016 at 11:30 PM, Noel O'Boyle <baoille...@gmail.com>
> wrote:
>
>> What exact OS and version are you using?
>>
>> On 5 Oct 2016 10:47 p.m., "Jason Ott" <jott...@ucr.edu> wrote:
>>
>>> The bindings get built just fine.  I the both the jar and jnilib files
>>> are created.  The problem that arises is when I try to run openbabel within
>>> my java application.  I implement the tutorial and I get:
>>> # A fatal error has been detected by the Java Runtime Environment:
>>> #
>>> #  SIGSEGV (0xb) at pc=0x000000011e879761, pid=62346, tid=6915
>>> ...
>>> Process finished with exit code 134
>>>
>>> The jar is in the classpath and the jni is loaded using: either
>>> System.load("/path/to/jnilib"); or System.loadLibrary("openbabel_java");
>>> where I add the jnilib to the class.path environment variable.  I assume
>>> I'm doing this part correctly.  But I could be mistaken.
>>>
>>> Thanks,
>>> Jason
>>>
>>> On Wed, Oct 5, 2016 at 1:07 PM, Noel O'Boyle <baoille...@gmail.com>
>>> wrote:
>>>
>>>> Sorry - missed that. It's best to ignore that README as you shouldn't
>>>> need to run g++ yourself. The bindings are built when you run "make &&
>>>> make install". Just make sure that CMake finds Eigen at the configure
>>>> step.
>>>>
>>>> If it still doesn't work please provide your CMakeCache.txt, and the
>>>> output of "VERBOSE=1 make", and maybe we can see where things are
>>>> going wrong.
>>>>
>>>> - Noel
>>>>
>>>> On 5 October 2016 at 19:01, Jason Ott <jott...@ucr.edu> wrote:
>>>> > I have eigen3 installed.  If you look at my gcc install command. I
>>>> had to
>>>> > add a path for it.  It's there and functional.
>>>> >
>>>> >
>>>> > On Oct 5, 2016 10:55, "Noel O'Boyle" <baoille...@gmail.com> wrote:
>>>> >>
>>>> >> This part is covered in the docs at least. You are missing eigen.
>>>> >>
>>>> >>
>>>> >> On 5 Oct 2016 6:02 p.m., "Jason Ott" <jott...@ucr.edu> wrote:
>>>> >>>
>>>> >>> That worked like a charm!  Thanks.  So now I have been trying to
>>>> include
>>>> >>> said java bindings in my project...
>>>> >>>
>>>> >>> I added the openbabel.jar file to my classpath.  So I can import
>>>> and all
>>>> >>> classes are resolved and looking good!  However, when I try running
>>>> the
>>>> >>> basic program from the tutorial my System.loadLibrary("openbabel_
>>>> java")
>>>> >>> throws a segfault from native up to my java.
>>>> >>>
>>>> >>> I tried to follow the readme in the /scripts/java/ directory, but I
>>>> >>> cannot get the very first compilation step to work.  But I noticed
>>>> that
>>>> >>> under [install_path]/lib/ there is both the openbabel.jar and
>>>> >>> libopenbabel_java.jnilib, which should be enough to get the thing
>>>> working.
>>>> >>>
>>>> >>> When I follow that readme in /scripts/java/ I get the following
>>>> error:
>>>> >>>
>>>> >>> openbabel-java.cpp:9941:25: error: no member named 'DiverseConfGen'
>>>> in
>>>> >>> 'OpenBabel::OBForceField'
>>>> >>>
>>>> >>>   result = (int)(arg1)->DiverseConfGen(arg2,arg3,arg4,arg5);
>>>> jresult =
>>>> >>> (jint)result;  return jresult; }
>>>> >>>
>>>> >>>                 ~~~~~~  ^
>>>> >>>
>>>> >>> openbabel-java.cpp:9946:25: error: no member named 'DiverseConfGen'
>>>> in
>>>> >>> 'OpenBabel::OBForceField'
>>>> >>>
>>>> >>>   result = (int)(arg1)->DiverseConfGen(arg2,arg3,arg4); jresult =
>>>> >>> (jint)result;  return jresult; }
>>>> >>>
>>>> >>>                 ~~~~~~  ^
>>>> >>>
>>>> >>> openbabel-java.cpp:9950:54: error: no member named 'DiverseConfGen'
>>>> in
>>>> >>> 'OpenBabel::OBForceField'
>>>> >>>
>>>> >>>   arg3 = (unsigned int)jarg3;  result =
>>>> >>> (int)(arg1)->DiverseConfGen(arg2,arg3); jresult = (jint)result;
>>>> return
>>>> >>> jresult; }
>>>> >>>
>>>> >>>                                              ~~~~~~  ^
>>>> >>>
>>>> >>> openbabel-java.cpp:9954:25: error: no member named 'DiverseConfGen'
>>>> in
>>>> >>> 'OpenBabel::OBForceField'
>>>> >>>
>>>> >>>   result = (int)(arg1)->DiverseConfGen(arg2); jresult =
>>>> (jint)result;
>>>> >>> return jresult; }
>>>> >>>
>>>> >>>                 ~~~~~~  ^
>>>> >>>
>>>> >>> 4 errors generated.
>>>> >>>
>>>> >>>
>>>> >>> I compile with the following command: g++ -c -fpic
>>>> openbabel-java.cpp -I
>>>> >>> ../../include/ -I
>>>> >>> /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/include/
>>>> -I
>>>> >>> /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/H
>>>> ome/include/darwin/
>>>> >>> -I /opt/local/include/eigen3/
>>>> >>>
>>>> >>>
>>>> >>> Any support would be appreciated.  Thanks.
>>>> >>>
>>>> >>>
>>>> >>> On Wed, Oct 5, 2016 at 6:48 AM, Noel O'Boyle <baoille...@gmail.com>
>>>> >>> wrote:
>>>> >>>>
>>>> >>>> Ah -- looks like we missed something in the release. The Swig
>>>> bindings
>>>> >>>> should have been included. As it is, you will need to install swig,
>>>> >>>> and specify -DSWIG_EXECUTABLE=whatever.
>>>> >>>>
>>>> >>>> - Noel
>>>> >>>>
>>>> >>>> On 5 October 2016 at 01:10, Jason Ott <jott...@ucr.edu> wrote:
>>>> >>>> > Hello all!
>>>> >>>> >
>>>> >>>> > I have been trying all day to build the java bindings for open
>>>> babel.
>>>> >>>> > I
>>>> >>>> > have:
>>>> >>>> >
>>>> >>>> > installed through mac ports,
>>>> >>>> > downloaded source and compiled using the following flags:
>>>> >>>> >
>>>> >>>> > -DCMAKE_INSTALL_PREFIX=~/Applications/openbabel
>>>> -DJAVA_BINDINGS=ON
>>>> >>>> > -DBUILD_GUI=OFF
>>>> >>>> >
>>>> >>>> > I am running MacOS Sierra.  No special configs or anything.  The
>>>> java
>>>> >>>> > bindings are never generated in the
>>>> >>>> > openbabel-openbabel-2.4.0/scripts/java/
>>>> >>>> > folder or anywhere in the installation location.
>>>> >>>> >
>>>> >>>> > When I do the "cmake ./
>>>> >>>> > -DCMAKE_INSTALL_PREFIX=~/Applications/openbabel
>>>> >>>> > -DJAVA_BINDINGS=ON -DBUILD_GUI=OFF" I  get the following output:
>>>> >>>> >
>>>> >>>> > -- Using included inchi library.
>>>> >>>> > -- Could NOT find wxWidgets (missing:  wxWidgets_LIBRARIES
>>>> >>>> > wxWidgets_INCLUDE_DIRS)
>>>> >>>> > -- Checking available shared pointer...
>>>> >>>> > -- Use std::shared_ptr in memory
>>>> >>>> > -- Cairo found. PNG output will be supported.
>>>> >>>> > -- GUI will not be built
>>>> >>>> > -- Could NOT find SWIG (missing:  SWIG_EXECUTABLE SWIG_DIR)
>>>> >>>> > -- Could NOT find SWIG (missing:  SWIG_EXECUTABLE SWIG_DIR)
>>>> (Required
>>>> >>>> > is at
>>>> >>>> > least version "2.0")
>>>> >>>> > -- SWIG 2.0 NOT found
>>>> >>>> > -- Configuring done
>>>> >>>> > -- Generating done
>>>> >>>> > -- Build files have been written to:
>>>> >>>> > /Users/jason/Desktop/openbabel-openbabel-2-4-0
>>>> >>>> >
>>>> >>>> > So that tells me that that java AND python bindings should exist
>>>> >>>> > *somewhere*
>>>> >>>> > but they don't.
>>>> >>>> >
>>>> >>>> > Thanks,
>>>> >>>> >
>>>> >>>> > Jason
>>>> >>>> >
>>>> >>>> >
>>>> >>>> > ------------------------------------------------------------
>>>> ------------------
>>>> >>>> > Check out the vibrant tech community on one of the world's most
>>>> >>>> > engaging tech sites, SlashDot.org! http://sdm.link/slashdot
>>>> >>>> > _______________________________________________
>>>> >>>> > OpenBabel-discuss mailing list
>>>> >>>> > OpenBabel-discuss@lists.sourceforge.net
>>>> >>>> > https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
>>>> >>>> >
>>>> >>>
>>>> >>>
>>>> >
>>>>
>>>
>>>
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to