64-bit 32-bit dll calls jdk

 

delphi part java attempted translated into logical thought package dll

They do nothing to export 32-bit dll, cut jdk version is not suitable

Try some of the online approach, technology is not up to finally engage with java slightly, hundreds of times

 

My general idea: write a java call the dll file, cmd run with 32-bit jdk, program execution cmd command

 

1, ready: jdk, jna.jar

2, write a call dll methods (keyword replace lost)

import com.sun.jna.Library;
import com.sun.jna.Native;

public class testDll {

    public static void main(String[] args) {
        System.load(args[1]+"****.dll");
        testDll.testInter test = (testDll.testInter) Native.loadLibrary("****", testInter.class);
        System.out.println(test.test(args[0]));
    }

    public interface testInter extends Library {
        public String test(String str);
    }
}

3, compile, I jna, jar into the bin directory

D:
cd D:\softwares\Java\java32\jdk1.7.0_65\bin
javac.exe -classpath jna-4.1.0.jar testDll.java

4, the test results

Pass two parameters, 
the directory where the dll as a parameter passed over 

java.exe -cp; JNA-4.1.0.jar passEncode TestStr D:. \

 

java调用:

Process process = Runtime.getRuntime().exec("cmd /c cd "+path+" &&java -cp .;jna-4.1.0.jar testDll "+str + " "+path+"/");
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
while((line=reader.readLine())!=null){result.append(line);}
reader.close();
process.destroy();

 

Be able to solve my problem, but could not use also requested the exhibitions

Guess you like

Origin www.cnblogs.com/luowusheng/p/11096143.html