Creating .dll for JNI -- Common Error?

Discussion in 'Java' started by cppaddict, Jun 16, 2004.

  1. cppaddict

    cppaddict Guest

    Hi,

    I'm learning JNI, and I went through the steps of this tutorial
    verbatim to create the sample HelloWorld app:

    http://java.sun.com/docs/books/tutorial/native1.1/stepbystep/index.html

    I got everything to compile correctly (both the java and the native
    ..dll) but I get an error when I run the program with "java
    HelloWorld".

    The error is:

    The application or DLL C:\Borland\JNI\hello.dll is not a valid Windows
    image. Please check this against your installation diskette.

    Also, the command line output is:

    Exception in thread "main" java.lang.UnsatisfiedLinkError:
    C:\Borland\JNI\hello.
    dll: %1 is not a valid Win32 application
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1560)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1485)
    at java.lang.Runtime.loadLibrary0(Runtime.java:788)
    at java.lang.System.loadLibrary(System.java:834)
    at HelloWorld.<clinit>(HelloWorld.java:5)

    Does anyone know what might be going wrong?

    Thanks,
    cpp

    PS: The application was compiled using borland's bcc32 on WindowsXP.
     
    cppaddict, Jun 16, 2004
    #1
    1. Advertising

  2. cppaddict

    cppaddict Guest

    I figured out (partially) what was wrong. When I changed the name of
    the loaded .dll to from "hello" to "HelloWorld" (see the tutorial
    referenced in my original post for more info) everything worked fine.
    This *seems* to suggest that something is going wrong with Borland's
    bcc32 "-o" option. When I used that option like so:

    bcc32 -tWD -IC:\j2sdk1.4.2_04\include;C:\j2sdk1.4.2_04\include\win32
    -ohello.dll HelloWorld.cpp

    Borland was producing hello.dll as well as HelloWorld.dll, but only
    the HelloWorld.dll was correct. In any case, I think this makes the
    issue off-topic here and more appopriate to a Borland newsgroup.

    cpp
     
    cppaddict, Jun 17, 2004
    #2
    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. vasanth
    Replies:
    0
    Views:
    2,702
    vasanth
    Jan 25, 2005
  2. vasanth
    Replies:
    0
    Views:
    623
    vasanth
    Jan 25, 2005
  3. pcarr01
    Replies:
    3
    Views:
    666
    Gordon Beaton
    Feb 17, 2005
  4. Denny
    Replies:
    1
    Views:
    783
  5. John Reye
    Replies:
    28
    Views:
    1,375
    Tim Rentsch
    May 8, 2012
Loading...

Share This Page