how to use .dll files in java code?

2019-03-06 09:22发布

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 
}

3条回答
闹够了就滚
2楼-- · 2019-03-06 09:51

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

查看更多
forever°为你锁心
3楼-- · 2019-03-06 10:11

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

https://github.com/twall/jna

查看更多
爱情/是我丢掉的垃圾
4楼-- · 2019-03-06 10:17

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

查看更多
登录 后发表回答