Problems with java interface

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Problems with java interface

David Jessop
I've been having trouble trying to set up the java interface for use on a
Windows machine. Specifically, what I want to be able to do is call the
coordinate generation routines used by obgen from within a java program, so
I'm working with the openbabel-2.2.0b6 release.

Using the OpenBabelOBF solution in Microsoft Visual C++ 2008 I've been able
to compile the OBConsole project and get the format translation working
from the command line. I've also set up a new project to compile obgen and
I have this working from the command line. The OBJava project will compile,
but when I run OBTest.java it crashes out with error;

Exception in thread "main" java.lang.UnsatisfiedLinkError:
C:\babel\src\openbabel\openbabel-2.2.0b6\scripts\java\openbabel.dll: Can't
find dependent libraries
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary0(Unknown Source)
        at java.lang.ClassLoader.loadLibrary(Unknown Source)
        at java.lang.Runtime.loadLibrary0(Unknown Source)
        at java.lang.System.loadLibrary(Unknown Source)
        at OBTest.<init>(OBTest.java:5)
        at OBTest.main(OBTest.java:17)


Alternatively, if I use the DLLs required by babel.exe it crashes out with
the error;

Exception in thread "main" java.lang.UnsatisfiedLinkError:
openbabelJNI.new_OBConversion__SWIG_2()J
        at openbabelJNI.new_OBConversion__SWIG_2(Native Method)
        at OBConversion.<init>(OBConversion.java:44)
        at Foo.run(Foo.java:12)
        at Foo.main(Foo.java:22)

And if I use the DLL generated by solution openbabel (OpenBabelDLLD.dll), I
get the same error.

Does anyone have any suggestions for how I can solve/work around these
problems?


Thanks,

Dave

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Problems with java interface

Noel O'Boyle
Administrator
Hello from 20 yards away,

The short term solution is to download cinfony, which contains an
openbabel.jar file and all of the necessary DLLs, which you can use
straightaway. It's based on a version of OpenBabel from a week or so
ago. You need to set some environment variables, so look at
cinfony.bat.

With the release of OpenBabel 2.2 imminent, I haven't wanted to hurry
these changes into the OpenBabel distribution, but I will do so
afterwards. It's good to hear that someone is actually using the Java
interface, as otherwise there isn't much of a incentive to tidy it up.

Noel

2008/7/2 David Jessop <[hidden email]>:

> I've been having trouble trying to set up the java interface for use on a
> Windows machine. Specifically, what I want to be able to do is call the
> coordinate generation routines used by obgen from within a java program, so
> I'm working with the openbabel-2.2.0b6 release.
>
> Using the OpenBabelOBF solution in Microsoft Visual C++ 2008 I've been able
> to compile the OBConsole project and get the format translation working
> from the command line. I've also set up a new project to compile obgen and
> I have this working from the command line. The OBJava project will compile,
> but when I run OBTest.java it crashes out with error;
>
> Exception in thread "main" java.lang.UnsatisfiedLinkError:
> C:\babel\src\openbabel\openbabel-2.2.0b6\scripts\java\openbabel.dll: Can't
> find dependent libraries
>        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
>        at java.lang.ClassLoader.loadLibrary0(Unknown Source)
>        at java.lang.ClassLoader.loadLibrary(Unknown Source)
>        at java.lang.Runtime.loadLibrary0(Unknown Source)
>        at java.lang.System.loadLibrary(Unknown Source)
>        at OBTest.<init>(OBTest.java:5)
>        at OBTest.main(OBTest.java:17)
>
>
> Alternatively, if I use the DLLs required by babel.exe it crashes out with
> the error;
>
> Exception in thread "main" java.lang.UnsatisfiedLinkError:
> openbabelJNI.new_OBConversion__SWIG_2()J
>        at openbabelJNI.new_OBConversion__SWIG_2(Native Method)
>        at OBConversion.<init>(OBConversion.java:44)
>        at Foo.run(Foo.java:12)
>        at Foo.main(Foo.java:22)
>
> And if I use the DLL generated by solution openbabel (OpenBabelDLLD.dll), I
> get the same error.
>
> Does anyone have any suggestions for how I can solve/work around these
> problems?
>
>
> Thanks,
>
> Dave
>
> -------------------------------------------------------------------------
> Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
> Studies have shown that voting for your favorite open source project,
> along with a healthy diet, reduces your potential for chronic lameness
> and boredom. Vote Now at http://www.sourceforge.net/community/cca08
> _______________________________________________
> OpenBabel-discuss mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
>

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Problems with java interface

richard apodaca
David,

Another option would be to call the Open Babel binaries from Java with Runtime.getRuntime().exec():

http://www.devdaily.com/java/edu/pj/pj010016/pj010016.shtml

May not be suitable for every case, but it gets around the hard part, which is getting JNI to work.

___________________________________

Richard L. Apodaca

http://depth-first.com      Blog
http://metamolecular.com    Company


--- On Wed, 7/2/08, Noel O'Boyle <[hidden email]> wrote:

> From: Noel O'Boyle <[hidden email]>
> Subject: Re: [Open Babel] Problems with java interface
> To: "David Jessop" <[hidden email]>
> Cc: [hidden email]
> Date: Wednesday, July 2, 2008, 8:59 AM
> Hello from 20 yards away,
>
> The short term solution is to download cinfony, which
> contains an
> openbabel.jar file and all of the necessary DLLs, which you
> can use
> straightaway. It's based on a version of OpenBabel from
> a week or so
> ago. You need to set some environment variables, so look at
> cinfony.bat.
>
> With the release of OpenBabel 2.2 imminent, I haven't
> wanted to hurry
> these changes into the OpenBabel distribution, but I will
> do so
> afterwards. It's good to hear that someone is actually
> using the Java
> interface, as otherwise there isn't much of a incentive
> to tidy it up.
>
> Noel
>
> 2008/7/2 David Jessop <[hidden email]>:
> > I've been having trouble trying to set up the java
> interface for use on a
> > Windows machine. Specifically, what I want to be able
> to do is call the
> > coordinate generation routines used by obgen from
> within a java program, so
> > I'm working with the openbabel-2.2.0b6 release.
> >
> > Using the OpenBabelOBF solution in Microsoft Visual
> C++ 2008 I've been able
> > to compile the OBConsole project and get the format
> translation working
> > from the command line. I've also set up a new
> project to compile obgen and
> > I have this working from the command line. The OBJava
> project will compile,
> > but when I run OBTest.java it crashes out with error;
> >
> > Exception in thread "main"
> java.lang.UnsatisfiedLinkError:
> >
> C:\babel\src\openbabel\openbabel-2.2.0b6\scripts\java\openbabel.dll:
> Can't
> > find dependent libraries
> >        at
> java.lang.ClassLoader$NativeLibrary.load(Native Method)
> >        at java.lang.ClassLoader.loadLibrary0(Unknown
> Source)
> >        at java.lang.ClassLoader.loadLibrary(Unknown
> Source)
> >        at java.lang.Runtime.loadLibrary0(Unknown
> Source)
> >        at java.lang.System.loadLibrary(Unknown Source)
> >        at OBTest.<init>(OBTest.java:5)
> >        at OBTest.main(OBTest.java:17)
> >
> >
> > Alternatively, if I use the DLLs required by babel.exe
> it crashes out with
> > the error;
> >
> > Exception in thread "main"
> java.lang.UnsatisfiedLinkError:
> > openbabelJNI.new_OBConversion__SWIG_2()J
> >        at openbabelJNI.new_OBConversion__SWIG_2(Native
> Method)
> >        at
> OBConversion.<init>(OBConversion.java:44)
> >        at Foo.run(Foo.java:12)
> >        at Foo.main(Foo.java:22)
> >
> > And if I use the DLL generated by solution openbabel
> (OpenBabelDLLD.dll), I
> > get the same error.
> >
> > Does anyone have any suggestions for how I can
> solve/work around these
> > problems?
> >
> >
> > Thanks,
> >
> > Dave
> >
> >
> -------------------------------------------------------------------------
> > Sponsored by: SourceForge.net Community Choice Awards:
> VOTE NOW!
> > Studies have shown that voting for your favorite open
> source project,
> > along with a healthy diet, reduces your potential for
> chronic lameness
> > and boredom. Vote Now at
> http://www.sourceforge.net/community/cca08
> > _______________________________________________
> > OpenBabel-discuss mailing list
> > [hidden email]
> >
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
> >
>
> -------------------------------------------------------------------------
> Sponsored by: SourceForge.net Community Choice Awards: VOTE
> NOW!
> Studies have shown that voting for your favorite open
> source project,
> along with a healthy diet, reduces your potential for
> chronic lameness
> and boredom. Vote Now at
> http://www.sourceforge.net/community/cca08
> _______________________________________________
> OpenBabel-discuss mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Problems with java interface

Geoffrey Hutchison
In reply to this post by David Jessop

On Jul 2, 2008, at 11:44 AM, David Jessop wrote:

> Exception in thread "main" java.lang.UnsatisfiedLinkError:
> openbabelJNI.new_OBConversion__SWIG_2()J
> at openbabelJNI.new_OBConversion__SWIG_2(Native Method)
> at OBConversion.<init>(OBConversion.java:44)
> at Foo.run(Foo.java:12)
> at Foo.main(Foo.java:22)

This one, in particular, looks like it hasn't loaded the  
openbabel_java.cpp code. This is the JNI "glue" which connects the  
Java code to Open Babel.

Cheers,
-Geoff

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Problems with java interface

ozgun bursali
I got the exact same problem and I try almost everything to solve it. Can you pls help me??
Reply | Threaded
Open this post in threaded view
|

Re: Problems with java interface

fredrictam
In reply to this post by David Jessop
To create the interface in Java, you must first know the LayoutManager in Java, it is like a technical drawing for a house.
2 player games
Reply | Threaded
Open this post in threaded view
|

Re: Problems with java interface

nguyenthaovan
Thanks a lot for the post. It has helped me get some nice ideas. I hope I will see some really good result soon
gmail sign up
hotmail email login
Reply | Threaded
Open this post in threaded view
|

Re: Problems with java interface

arianapham
In reply to this post by David Jessop
Pretty great post. I just stumbled upon your blog and wanted to say that I’ve truly loved browsing your blog posts. wuxiaworld
Reply | Threaded
Open this post in threaded view
|

Re: Problems with java interface

alicetaylor
In reply to this post by David Jessop
A Java interface can only contain method signatures and fields. The interface can be used to achieve polymorphism.

learn to fly 3 game