how to use .dll files in java code?

﹥>﹥吖頭↗ 提交于 2020-01-22 03:00:48

问题


I have a .dll file, which i have to use in java. This .dll file has a parameterised method, which should return type as string. When i am passing parameter to it, i get the message as Native methods do not specify a body

Here is the Code...

package com.letme.test;

public class Eagleye_parser {

    String n = "E48A7 F7759 65EA7";

    public Eagleye_parser() {}

    static {
        System.loadLibrary("Eagleye_parser");
    }

    public native String eagleye_fmu(n);// here it is giving msg : Native methods do not specify a body 
}

回答1:


Simple add the reference in you project. and the namespace at the top.. then you can access the all dll methods. If your are using Eclispe then right click on your project->Then click on Build path-> then click on Add libraries after that click on user library

Here you can import the dll




回答2:


Try having a look at JNA, it provides a nice wrapper layer around native code.

https://github.com/twall/jna




回答3:


public native String eagleye_fmu(n); The 'n' here is the problem as it would be a problem with any other java function declaration.

This should be something like public native String eagleye_fmu(String); then you call the native function like any other function String result = eagleye_fmu(n);

This is all assuming you have the dll implemented properly



来源:https://stackoverflow.com/questions/10208914/how-to-use-dll-files-in-java-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!