Using OpenBabel in Java Snippets

Hello everyone,

I would like to use classes from openbabel for molecular descriptors. In both, the simple and normal Java Snippet, I can add the openbabel.jar as an external source. Importing the classes itself doe not appear to create any problems neither, however, once I call a constructor, I get an error message saying:


Evaluation of java snippet failed for row "Row0": org.openbabel.openbabel_javaJNI.new_OBMol__SWIG_0()J


which baffles me, because the same code works perfectly fine in Eclipse (After all, the two share the same Java underneath, don't they?)

I have tried to parse the exact Error created by putting the code in a try/catch block (code below), but the output is always '?', once I try to use the constructors.

Any ideas on this one?






OBMol mol = new OBMol();
return "successful";}

catch(Exception e){

StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
return sw.toString();



As you are working with native code, you might have to have the .dlls/.sos available (as I remember LD_LIBRARY_PATH on *n*x systems, and maybe PATH works for Windows). There might be additional settings required (in OSGi environment), which are not available in the Java Snippet nodes, so maybe you are out of luck with the native code using jars. (The SWIG documentation or checking JNI related posts on the internet might be more useful.)

Cheers, gabor

PS.: As I remember there are OpenBABEL nodes available. Do you need something special?

Hey aborg,

thx for your comment. I feared the same thing about the Java Snippet nodes, but I will check the SWIG doc again. AFAIC, there is one OpenBabel node available, which implements the 'babel' functionality, so easy to use file format conversion for molecules. Yet, I need the java classes implemented by OB for my algorithms. I guess I'd best try to set up my own node and see if the problem persists :).