19

For my JNLP file , there is some nativelib info like below:

<resources os="Windows">
    <nativelib href="lib/x264-win.jar" />
</resources>
<resources os="SunOS" arch="sparc">
    <nativelib href="lib/x264-SunOS-sparc.jar" />
</resources>
<resources os="SunOS" arch="x86">
    <nativelib href="lib/x264-SunOS-x86.jar" />
</resources>

When I Update To JRE7, can not load nativelib jar, but JRE6 works fine.

The load nativelib code like below:

String source = "x264.jar";
ClassLoader cl = Thread.currentThread().getContextClassLoader();
URL url= cl.getResource(source);

"x264.jar" is one jar in x264-win.jar,lib/x264-SunOS-sparc.jar or lib/x264-SunOS-x86.jar.

When I used JRE6 to load x264.jar, it worked fine. But when I updated to JRE7, it can not load x264.jar.

When use JRE6, url would be"x264.jar" info, like jar:http://test.local:8080/JNLP.jar!/x264.jar, but use JRE7, url would be null, and I found code not load nativelib "x264.jar"

Does any one have find JRE7 can not load nativelib.jar? Is the problem of using Thread.currentThread().getContextClassLoader() to load "x264.jar"?

8
  • Why is the code attempting to load the Jar, as opposed to loading a native lib inside the root of the (signed) Jar using the generic name (the lib file-name without any extension)? Jan 14, 2013 at 9:51
  • 1
    Having the same issue. My code attempts to load the library in the JAR with no luck. Works with JRE6, but not JRE7.
    – brostbeef
    May 10, 2013 at 17:28
  • 1
    @brostbeef - Maybe you should ask a new Question, preferably with an SSCCE. I for one am having a great deal of trouble working out what this Question is about. What is this JAR he is talking about? Are there any error messages or log messages? Which version of Java 7 are you / he using?
    – Stephen C
    Aug 5, 2013 at 4:34
  • 1
    Did you install Java 7 64 bit or 32 bit jre ?
    – bvdb
    Aug 13, 2013 at 11:25
  • Why are you using the ClassLoader for the thread? If you pull a reference to the ClassLoader for, say, the class in which this code resides, do you get different results? I.e., ClassLoader cl = this.getClass().getClassLoader(); You can also skip the ClassLoader entirely: URL url = this.getClass().getResource(source); Aug 15, 2013 at 21:25

4 Answers 4

1

Ensure that you have the correct bitwise native binary to match your JRE. If you are testing on a 64-bit JRE, you need a 64-bit native binary. If you're testing on a 32-bit JRE, you need a 32-bit native binary. You might need to include resources for each of these three:

<resources os="Windows" arch="amd64">
<resources os="Windows" arch="x86_64">
<resources os="Windows" arch="x86">
0

I had similar trouble ; however even in JRE 6 this didn't get this to work.

Found a bug that could be related to that :

https://bugs.java.com/bugdatabase/view_bug?bug_id=6758884

Apparently JRE can have trouble downloading nativelib resources.

The bug is still opened, and targeted towards version 8 of java ...

0

The following "dll relying" applet is working fine (besides the security problems when using 1.7.0_51 (you need to decrease the security settings to medium since it is self signed)). So if the native lib loading mechanism of the jnlp file is broken then you can distribute your .dll files alongside a normal jar file like in the upper example.

  1. Put the dlls/sos in your jar file like in the example: jssc.jar
  2. Load the libraries with System.load(libFolderPath + fileSeparator + libName); like used here.
  3. As mentioned by Joseph please note the fine grained version differentiation between win, solaris, linux, arm and i86 and amd64 bit systems. So if you e.g. don't supply a 64Bit dll and run it with 64Bit Java it won't work...
0

I had forgot I solved this a while ago. I found that I had to handle this in Java code with System.loadLibrary( "jarNameNoExtension" );

Hopefully that helps others.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.