JNI Unsatisfied Link Error on x86java on x64machine with x86javapath

UPDATE: I just check out DLL assembly and program shows an error for the DLL as follows:

Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module. Error: Modules with different CPU types were found.

I've been trying to develop a JNI implementation for 2 days now...

My laptop is x64 , i have both x64 and x86 java installed on my machine.. But java environment variables are set to x64 version.

I'm doing all work on x86 java , compiling , header-generation and also i compile dll for win32 on vs2010

First i code java class as:


public class Ex1 {
    // Load the dll that exports functions callable from java
    static {System.loadLibrary("ex1");}

    public native void startProcess();

    public void Test() {

    public static void main(String [] args) {
        Ex1 t = new Ex1();


Then i compile this java file with x86 javac

"C:\Program Files (x86)\Java\jdk1.7.0_05\bin\javac.exe" Ex1.java

Then i generate header with x86 javah

"C:\Program Files (x86)\Java\jdk1.7.0_05\bin\javah.exe" Ex1


/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class Ex1 */

#ifndef _Included_Ex1
#define _Included_Ex1
#ifdef __cplusplus
extern "C" {
 * Class:     Ex1
 * Method:    startProcess
 * Signature: ()V
JNIEXPORT void JNICALL Java_Ex1_startProcess
  (JNIEnv *, jobject);

#ifdef __cplusplus

Then i start a new Win32 project , set to dll & empty project on vs2010. And add javah generated header file to header files and then i create cpp file with same name as header file and then i implement function as :


#include <jni.h>

JNIEXPORT void JNICALL Java_Ex1_startProcess(JNIEnv * env, jobject job){

Then i compile project as ex1.dll

Then i put following files all together on C:/jni1/

  • ex1.h
  • ex1.java
  • ex1.class
  • ex1.dll

Finally , i run following command :

"C:\Program Files (x86)\Java\jdk1.7.0_05\bin\java.exe" -classpath .; Ex1

Then this error occures:

Exception in thread "main" java.lang.UnsatisfiedLinkError: Ex1.startProcess()V at Ex1.startProcess (Native Method) at Ex1.main (ex1.java:20)


I guess that your 32bit DLL depends on system DLLs and tries to use those from System32 which despite the name are 64bit, not 32bit which happen to be in SysWoW64. As a proof i would try to compile your DLL as 64bit and try to run through 64bit JVM. That should work out of the box. However i can't help with forcing your 32bit DLL to use 32bit dependencies. Never did that and it might involve some tricky copying of files to where your JNI DLL resides, and/or registry magic. Though proper DLL registration through 32bit tool might be enough.

Need Your Help

Label axes on Seaborn Barplot

python matplotlib seaborn

I'm trying to use my own labels for a Seaborn barplot with the following code:

Highest and lowest elements in trove TIntSet?

java collections sortedset trove4j

TIntSet is "sorted set" by sense, i.e. it's elements have natural order.