Java Webstart and JNI

Discussion in 'Java' started by Henri, Sep 15, 2003.

  1. Henri

    Henri Guest

    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
    Henri, Sep 15, 2003
    #1
    1. Advertising

  2. 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

    "Henri" <> skrev i en meddelelse
    news:...
    > 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
    Morten Nørgaard, Sep 15, 2003
    #2
    1. Advertising

  3. Henri

    Roedy Green Guest

    On 15 Sep 2003 04:42:29 -0700, (Henri) wrote
    or quoted :

    >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.

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Sep 15, 2003
    #3
  4. Henri

    Roedy Green Guest

    On Mon, 15 Sep 2003 15:28:26 +0200, "Morten Nørgaard"
    <> wrote or quoted :

    > <nativelib href="SPSSio32.jar"></nativelib>
    > <nativelib href="Nat.jar"></nativelib>


    Is that a new feature?

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Sep 15, 2003
    #4
  5. Henri

    Dale King Guest

    "Roedy Green" <> wrote in message
    news:...
    > On 15 Sep 2003 04:42:29 -0700, (Henri) wrote
    > or quoted :
    >
    > >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.



    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>

    --
    Dale King
    Dale King, Sep 22, 2003
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Carsten Zerbst

    webstart and java.util.Preferences ?

    Carsten Zerbst, Jul 16, 2003, in forum: Java
    Replies:
    1
    Views:
    535
    S. Balk
    Jul 16, 2003
  2. yuen

    Java WebStart

    yuen, Sep 7, 2003, in forum: Java
    Replies:
    1
    Views:
    399
    David Rabinowitz
    Sep 7, 2003
  3. Alex Schonlinner

    Java WebStart and JFileChooser

    Alex Schonlinner, Feb 27, 2004, in forum: Java
    Replies:
    0
    Views:
    525
    Alex Schonlinner
    Feb 27, 2004
  4. Tarlika Elisabeth Schmitz

    Java Webstart hangs and gobbles up 95% CPU

    Tarlika Elisabeth Schmitz, Aug 24, 2006, in forum: Java
    Replies:
    0
    Views:
    949
    Tarlika Elisabeth Schmitz
    Aug 24, 2006
  5. Replies:
    2
    Views:
    346
    Richard Maher
    Mar 8, 2008
Loading...

Share This Page