Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: JNI Lib Location when Loading from Java Applet on OS 10.2



Noa Yissar <email@hidden> wrote:

>I tried doing all the workarounds with the path
>location and supplying the full path in the
>System.loadLibrary() call and it still doesn't work.

It would help to know why it doesn't work, i.e. what exception is being thrown.

However, it's not supposed to work when the JAR is downloaded from the
server and the JNI-lib is located on the local host. It would be a
potential security flaw if it did. The class (or classes) containing the
'native' methods must have the same code-base as where the JNI-lib itself
is located. You can't separate them.

You don't have to put all your classes, nor the entire applet's jar, on the
local host. You just have to put the classes that contain the 'native'
methods on the local host, in a jar-file if you wish. And they should be
in the same location as the JNI-lib file.

Since you need some kind of installer to put the JNI-lib on the local host
anyway, I suggest that you install a minimal jar-file at the same time, in
the same place. The easiest place to install these components will be
~/Library/Java/Extensions, because you won't need root privileges to do it.
The classes will be available to that user-account, but no other. This
shouldn't be a serious problem, and is probably less of a problem than the
security implications of installing it in a root-writable extensions
location.

You should be able to create a signed applet to do the install on the
active user-account, though the installed library may not be usable until
the next time the browser is launched. That's because the contents of the
extensions dirs is only examined when the JVM is initialized, AFAIK. In
essence, you have to "reboot the JVM" in order for it to see the
just-installed extensions.

The only other alternative I can think of is to deploy as a JNLP (Java Web
Start) application. JNLP supports JNI-libs bundled into jar-files as
resources. JNLP has its own set of problems and bugs, though, so there's
no free ride waiting there.


>My java jar and native code are not located in the
>same extensions folder since the jar file is
>downloaded from a server... still, it is able to load
>the library from
>/System/Library/Frameworks.../Libraries location.

That location works because that's a location designated in the boot
library path, by the "sun.boot.library.path" property. That location
doesn't have the same lib-loading security constraints as other locations
do. Since it's writable only by root, it's operating under different
security premises, so it doesn't need its restrictions enforced by a
ClassLoader or AccessController.

-- GG
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Be sure to read the FAQ http://developer.apple.com/java/faq/ before posting
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.