Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Creating .dll for JNI -- Common Error?

Thread Tools

Creating .dll for JNI -- Common Error?

Posts: n/a

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

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

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:
dll: %1 is not a valid Win32 application
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.jav a:1560)
at java.lang.ClassLoader.loadLibrary( :1485)
at java.lang.Runtime.loadLibrary0(
at java.lang.System.loadLibrary(
at HelloWorld.<clinit>(

Does anyone know what might be going wrong?


PS: The application was compiled using borland's bcc32 on WindowsXP.

Reply With Quote
Posts: n/a

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.


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can *common* struct-members of 2 different struct-types, that are thesame for the first common members, be accessed via pointer cast to either struct-type? John Reye C Programming 28 05-08-2012 12:24 AM
java.lang.NoSuchMethodError: wm.common.session.Common.getCustRptListFromMax Denny Java 1 05-01-2008 07:33 AM
Re: JNI: Error loading DLL from JNI DDL vasanth Java 0 01-25-2005 11:01 AM
Porting JNI Windows under JNI LINUX + Wine ? Pasturel Jean-Louis Java 5 03-03-2004 07:50 PM
IBM's JNI fails where Sun's JNI works Alex Hunsley Java 4 11-04-2003 10:34 AM