|
View:
New views
8 Messages
—
Rating Filter:
Alert me
|
|
|
Loading java native extensionsHow does one load a dll from JRuby? I have Java wrapper classes (generated by SWIG) that wrap C++ code. Before referencing the Java classes, I need to load the DLL. I tried the following:
irb(main):001:0> java.lang.System.load_library('mydll') NativeException: java.lang.UnsatisfiedLinkError: no mydll in java.library.path from java/lang/ClassLoader.java:1682:in `loadLibrary' from java/lang/Runtime.java:822:in `loadLibrary0' from java/lang/System.java:992:in `loadLibrary' from sun/reflect/NativeMethodAccessorImpl.java:-2:in `invoke0' from sun/reflect/NativeMethodAccessorImpl.java:39:in `invoke' from sun/reflect/DelegatingMethodAccessorImpl.java:25:in `invoke' from java/lang/reflect/Method.java:585:in `invoke' ... mydll.dll is in the PATH. The following java code executed in the same directory, works without a problem: public class Test { public static void main(String[] args) { System.out.println("Before"); System.loadLibrary("mydll"); System.out.println("After"); } } Is there something that I'm missing? Or a better way to do this? Thanks, Tim --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Loading java native extensionsOn Tue, Jun 30, 2009 at 3:44 PM, Timothy
Hanson<thanson@...> wrote: > How does one load a dll from JRuby? I have Java wrapper classes (generated by SWIG) that wrap C++ code. Before referencing the Java classes, I need to load the DLL. I tried the following: Hmm...I believe we do twiddle java.library.path to support native libraries via FFI/JFFI/JNA. Perhaps what we're doing is interfering with loading other libraries? Any thoughts on this Wayne? - Charlie --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Loading java native extensions2009/7/2 Charles Oliver Nutter <headius@...>:
> On Tue, Jun 30, 2009 at 3:44 PM, Timothy > Hanson<thanson@...> wrote: >> How does one load a dll from JRuby? I have Java wrapper classes (generated by SWIG) that wrap C++ code. Before referencing the Java classes, I need to load the DLL. I tried the following: > > Hmm...I believe we do twiddle java.library.path to support native > libraries via FFI/JFFI/JNA. Perhaps what we're doing is interfering > with loading other libraries? > > Any thoughts on this Wayne? We don't twiddle java.library.path or LD_LIBRARY_PATH at all. JNA and JFFI both have a custom {jna,jffi}.boot.library.path they understand to load their stub libraries from, but when loading other libraries, they both use the standard LD_LIBRARY_PATH (or equivalent). --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Loading java native extensionsOn Wed, Jul 1, 2009 at 3:57 PM, Wayne Meissner<wmeissner@...> wrote:
> We don't twiddle java.library.path or LD_LIBRARY_PATH at all. > > JNA and JFFI both have a custom {jna,jffi}.boot.library.path they > understand to load their stub libraries from, but when loading other > libraries, they both use the standard LD_LIBRARY_PATH (or equivalent). Ok, thanks Wayne. Tim: Maybe you can try to run JRuby without the startup script, as in java -cp lib/jruby.jar org.jruby.Main script_which_uses_dll.rb If you can get it working that way, as you did with normal Java code, then the problem could be in our startup script. - Charlie --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
RE: Loading java native extensionsI was able to get it to work by embedding the System.loadLibrary() directly in the Java code and invoking that from JRuby.
-----Original Message----- From: Charles Oliver Nutter [mailto:headius@...] Sent: Thursday, July 02, 2009 9:49 AM To: user@... Subject: Re: [jruby-user] Loading java native extensions On Wed, Jul 1, 2009 at 3:57 PM, Wayne Meissner<wmeissner@...> wrote: > We don't twiddle java.library.path or LD_LIBRARY_PATH at all. > > JNA and JFFI both have a custom {jna,jffi}.boot.library.path they > understand to load their stub libraries from, but when loading other > libraries, they both use the standard LD_LIBRARY_PATH (or equivalent). Ok, thanks Wayne. Tim: Maybe you can try to run JRuby without the startup script, as in java -cp lib/jruby.jar org.jruby.Main script_which_uses_dll.rb If you can get it working that way, as you did with normal Java code, then the problem could be in our startup script. - Charlie --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Loading java native extensionsOn Thu, Jul 2, 2009 at 4:11 PM, Timothy
Hanson<thanson@...> wrote: > I was able to get it to work by embedding the System.loadLibrary() directly in the Java code and invoking that from JRuby. Now that's very interesting...I wonder if the logic for binding libraries or handling security doesn't like the load call from JRuby because we're loading on the boot classloader. You could probably try running JRuby with --debug also, which will load it on the normal system classloader. If that works, we have our culprit. Glad to hear you got it working, at any rate. - Charlie --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
RE: Loading java native extensionsI tried with --debug, it still failed.
-----Original Message----- From: Charles Oliver Nutter [mailto:headius@...] Sent: Thursday, July 02, 2009 2:23 PM To: user@... Subject: Re: [jruby-user] Loading java native extensions On Thu, Jul 2, 2009 at 4:11 PM, Timothy Hanson<thanson@...> wrote: > I was able to get it to work by embedding the System.loadLibrary() directly in the Java code and invoking that from JRuby. Now that's very interesting...I wonder if the logic for binding libraries or handling security doesn't like the load call from JRuby because we're loading on the boot classloader. You could probably try running JRuby with --debug also, which will load it on the normal system classloader. If that works, we have our culprit. Glad to hear you got it working, at any rate. - Charlie --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Loading java native extensionsHmm, I guess I'm stumped then. Maybe someone can try to investigate
further, but at the very least it would be good to get a bug report filed for it. Can you do that? On Thu, Jul 2, 2009 at 4:37 PM, Timothy Hanson<thanson@...> wrote: > I tried with --debug, it still failed. > > -----Original Message----- > From: Charles Oliver Nutter [mailto:headius@...] > Sent: Thursday, July 02, 2009 2:23 PM > To: user@... > Subject: Re: [jruby-user] Loading java native extensions > > On Thu, Jul 2, 2009 at 4:11 PM, Timothy > Hanson<thanson@...> wrote: >> I was able to get it to work by embedding the System.loadLibrary() directly in the Java code and invoking that from JRuby. > > Now that's very interesting...I wonder if the logic for binding > libraries or handling security doesn't like the load call from JRuby > because we're loading on the boot classloader. You could probably try > running JRuby with --debug also, which will load it on the normal > system classloader. If that works, we have our culprit. > > Glad to hear you got it working, at any rate. > > - Charlie > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
| Free embeddable forum powered by Nabble | Forum Help |