Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

native

jnlp

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

like image 316
Andy Avatar asked Jan 13 '13 12:01

Andy


1 Answers

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">
like image 141
Joseph Fitzgerald Avatar answered Oct 17 '22 14:10

Joseph Fitzgerald