ravi
ravi

Reputation: 75

how to use .dll files in java code?

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 
}

Upvotes: 1

Views: 10132

Answers (3)

msam
msam

Reputation: 4287

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

Upvotes: 0

Rahul Kumar
Rahul Kumar

Reputation: 524

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

Upvotes: 0

Aidos
Aidos

Reputation: 2765

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

https://github.com/twall/jna

Upvotes: 2

Related Questions