Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Calling native methods in a package

843829Jun 18 2002 — edited Jun 21 2002
Hi!

We have a problem when calling native methods in a class which is in a package. As you can see from the code below we have a class making an instance of a class<testBando> which makes a instance of another class<Bando> which contains the native methods. When running the program we get the error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: initialize
at test2.Bando.initialize(Native Method)
at test.testBando.<init>(testBando.java:10)
at Main.main(Main.java:5)

When we take the class that calls the native methods out of any package every thing works fine! Can you not call native methods inside a package or what are we doing wrong?

// testBando.java
package test;

import test2.*;

public class testBando {
Bando b;

public testBando() {
b = new Bando();
b.initialize();
}
}

// Bando.java
package test2;

public class Bando {
public native void initialize();
static {
System.loadLibrary("bando");
}
}

// Main.java
import test.*;

public class Main {
public static void main(String[] args) {
new testBando();
}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 19 2002
Added on Jun 18 2002
5 comments
178 views