S
smita b via JavaKB.com
I am trying to use native methods in java .Code is like :-
aaa.java :-
class aaa
{ public static void main(String s[])
{ bbb a;
System.out.println("Start");
a = new bbb();
System.out.println("Before xx");
a.xx();
System.out.println("After xx");
}
}
class bbb
{ public native void xx();
public bbb()
{
System.out.println("in bbb");
System.loadLibrary("sss");
}
}
sss.c :-
#include <windows.h>
void *Java_bbb_xx_stub(void * p)
{ MessageBox(0,"Hi","Hi",0);
return p;
}
sss.def :-
LIBRARY sss
EXPORTS
Java_bbb_xx_stub
I have created a sss.dll & aaa.h also.
when using java aaa at command prompt.
I am getting error as :-
Exception in thread "main" java.lang.UnsatisfiedLinkError: xx
at bbb.xx(Native Method)
at aaa.main(aaa.java:9)
What should I do?
aaa.java :-
class aaa
{ public static void main(String s[])
{ bbb a;
System.out.println("Start");
a = new bbb();
System.out.println("Before xx");
a.xx();
System.out.println("After xx");
}
}
class bbb
{ public native void xx();
public bbb()
{
System.out.println("in bbb");
System.loadLibrary("sss");
}
}
sss.c :-
#include <windows.h>
void *Java_bbb_xx_stub(void * p)
{ MessageBox(0,"Hi","Hi",0);
return p;
}
sss.def :-
LIBRARY sss
EXPORTS
Java_bbb_xx_stub
I have created a sss.dll & aaa.h also.
when using java aaa at command prompt.
I am getting error as :-
Exception in thread "main" java.lang.UnsatisfiedLinkError: xx
at bbb.xx(Native Method)
at aaa.main(aaa.java:9)
What should I do?