Creating .dll for JNI -- Common Error?

C

cppaddict

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

cppaddict

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
 

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

Similar Threads


Members online

No members online now.

Forum statistics

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

Latest Threads

Top