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"?

Darin Kolev
  • 3,401
  • 13
  • 31
  • 46
Andy
  • 199
  • 3
  • 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)? – Andrew Thompson Jan 14 '13 at 09: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 '13 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 05 '13 at 04:34
  • 1
    Did you install Java 7 64 bit or 32 bit jre ? – bvdb Aug 13 '13 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); – Bill Horvath Aug 15 '13 at 21:25
  • Enable full logging in the java console. This prints out internal logging from the JAva Webstart code and may help you identify the change. My guess would be that the operating system identifier changed. – Thorbjørn Ravn Andersen Oct 16 '13 at 21:56
  • Why don't you use 'System.loadLibrary(name);' or 'System.load(name)' functions to load your lib? – Lonzak Feb 18 '14 at 21:13
  • @andy, did my answer help you? – Joseph Fitzgerald Jul 13 '16 at 15:07

4 Answers4

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 :

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6758884

Apparently JRE can have trouble downloading nativelib resources.

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

hkara
  • 19
  • 3
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...
Lonzak
  • 9,334
  • 5
  • 57
  • 88
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.

brostbeef
  • 366
  • 3
  • 15