JNI

Gregg Wonderly gregg at wonderly.org
Tue Feb 14 05:44:28 PST 2012


On 2/14/2012 5:41 AM, Michael Hall wrote:
> On Feb 14, 2012, at 2:45 AM, Michael McMahon wrote:
>
>> Loading native libraries from the classpath sounds very strange to me. Can anyone shed some light
>> on the reason why that was done?
> Although thinking about it a little more this wouldn't be terribly difficult and might not be a bad enhancement.
>
> 	static {
> 		ClassLoader cl = new java.net.URLClassLoader(new java.net.URL[0]);
> 		templatePath = cl.getResource("hp/cmdjhtml.stg").getFile();		
> 	}
>
> Finds a arbitrary file somewhere off of classpath.
> This might facilitate deploying native libs?

To load JNI libraries, I put them in the jar, and then copy them out to temp 
space on the users machine, and then use load() instead of loadLibrary() to load 
them. That makes it very easy to bring whatever native code you need with the 
Jar and use it effectively.

Gregg Wonderly


More information about the macosx-port-dev mailing list