java - JNI Windows Netbeans Unsatisfied Link Error -


i following guide "how create jni netbeans":

using code question:

i have generated .dll , package file unsure them; how tell java find them using netbeans?

my java code:

package addingcontrollerstogui;  import javafx.application.application; import javafx.fxml.fxmlloader; import javafx.scene.parent; import javafx.scene.scene; import javafx.stage.stage;  public class addingcontrollerstogui extends application {      public native int intmethod(int i);      @override     public void start(stage stage) throws exception {         parent root = fxmlloader.load(getclass().getresource("sample.fxml"));         scene scene = new scene(root);                 stage.setscene(scene);         stage.show();          system.loadlibrary("main");         system.out.println(new addingcontrollerstogui().intmethod(2));     } 

my c code:

#include "addingcontrollerstogui.h" jint jnicall java_addingcontrollerstogui_addingcontrollerstogui_intmethod (jnienv * env, jobject object, jint param1) { return param1 * param1; } 

you need load dll program. edit , insert following java code, right before native method:

static {     system.load("yournetbeansfolder\\yourproject\\dist\\yournative.dll"); } 

static{} run method when addingcontrollerstogui first accessed (so before intmethod() called).

obviously, folder in code need modified point location of dll.

when build , distribute program, you'll need figure out how want dll loaded. instance, in minecraft, dll/so (so "dll" of unix-based oss) files used extracted %appdata%/.minecraft/ (or ~/.minecraft in unix-like) , loaded there.

for now, should suffice...!


Comments