Java Webstart and JNI

H

Henri

Hi all,

I have an application in Java accessing some DLLs written in C++ using
JNI. I'd like now to use JWS to deploy this application. Is there a
way to use JNI to load DLLs I would for example put in a JAR file ?

One solution I guess, would be to pack the DLLs in a JAR, load it and
then write the DLLs to disk and load them. Has anyone already tried
something like this ? Does anybody know of a better solution ?

Any help/advice will be most welcome.

Thanx,

Henri
 
M

Morten Nørgaard

Hah! Finally one I know the answer to :)

You can state, in your jnlp-file, the JNI dll's to load, and, yes, you pack
them in a jar. Like this:

<resources>
<j2se version="1.4+" />
<jar href="SPSSImageViewerJar.jar"/>

this is it:
<nativelib href="SPSSio32.jar"></nativelib>
<nativelib href="Nat.jar"></nativelib>

<extension href="jai.jnlp"/>
<extension href="helpjnlp.jnlp"/>
</resources>


Then just import them like you would normally, say:

// import c++ dll.
static
{
System.loadLibrary( "spssio32" );
System.loadLibrary( "strlen" );
}

Piece of cake.

Best,

Morten
 
R

Roedy Green

I have an application in Java accessing some DLLs written in C++ using
JNI. I'd like now to use JWS to deploy this application. Is there a
way to use JNI to load DLLs I would for example put in a JAR file ?

In your JWS install class is unpack the DLLs out of a jar and put them
somewhere on the path.
 
D

Dale King

Roedy Green said:
In your JWS install class is unpack the DLLs out of a jar and put them
somewhere on the path.


You don't have to do that. The JWW client will do it for you if you follow
the procedure Morten described. And no that is not a new feature. Quoting
the 1.01 version of the WebStart developer's guide:

A nativelib element specifies a JAR file that contains native libraries.
For example:

<nativelib href="lib/windows/corelib.jar"/>

The JNLP Client must ensure that each file entry in the root directory of
the JAR file (i.e., /) can be loaded into the running process using the
System.loadLibrary method. Each entry must contain a platform-dependent
shared library with the correct naming convention, e.g., *.dll on Windows,
or lib*.so on Solaris/Linux. The application is responsible for doing the
actual call to System.loadLibrary.

Native libraries would typically be included in a resources element that is
guarded against a particular operating system and architecture. For
example:

<resources os="SunOS" arch="sparc">
<nativelib href="lib/solaris/corelibs.jar"/>
</resource>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top