<none>

"Bhargavi" <[email protected]> Wed, 13 Nov 2002 06:41:21 -0500 (EST)
Newsgroups gmane.comp.web.jigsaw
Message-ID <001001c28b0a$48f477b0$0400a8c0@bhargavi>


This is a multi-part message in MIME format.

------=_NextPart_000_000D_01C28B38.4F89B710
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi

I am calling mydll.dll which is created in VC++ simple Dll, in JAVA. I =
am getting Java.Lang.UnSatisfiedLinkError exception.=20
Can you guide me on this???

Here my Java Code ::

public class myclass

{
 public native void mydll(String msg);
 static=20
 {

  System.loadLibrary("mydll");
 }
 public static void main(String args[])
 {
 myclass mc =3D new myclass();
 System.out.println("before");
 mc.mydll("hello");
  System.out.println("After");
 }
}

I have compiled myclass.java. Then javah -jni myclass to produce =
myclass.h file.

Here my VC++ code :

#include "stdafx.h"
#include <c:\jdk1.3\include\jni.h>
#include <stdio.h>
#include "c:\tryal\myclass.h"


BOOL APIENTRY DllMain( HANDLE hModule,=20
                       DWORD  ul_reason_for_call,=20
                       LPVOID lpReserved
      )
{
    return TRUE;
}


extern "C" JNIEXPORT void JNICALL=20
Java_ShowMessage_ShowMessage(JNIEnv* env,=20
jobject, jstring jMsg) {
  const char* msg=3Denv->GetStringUTFChars(jMsg,0);
  printf("Thinking in Java, JNI: %s\n", msg);
  env->ReleaseStringUTFChars(jMsg, msg);
}


I could compile entire dll. Copied dll at  Winnt\system32 on my machine.

then i typed following at dos prompt :
=20
java myclass

This gave me  :=20
Exception in thread "main" java.lang.UnsatisfiedLinkError: mydll
        at myclass.mydll(Native Method)
        at myclass.main(myclass.java:14)

Can u pls solve this??

thanks

Bhargavi

------=_NextPart_000_000D_01C28B38.4F89B710
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I am calling mydll.dll which is created =
in VC++=20
simple Dll, in JAVA. I am getting Java.Lang.UnSatisfiedLinkError =
exception.=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Can you guide me on =
this???</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><STRONG>Here my Java Code =
::</STRONG></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>public class myclass</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>{<BR>&nbsp;public native void =
mydll(String=20
msg);<BR>&nbsp;static <BR>&nbsp;{</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;System.loadLibrary("mydll");<BR>&nbsp;}<BR>&nbsp;pub=
lic=20
static void main(String args[])<BR>&nbsp;{<BR>&nbsp;myclass mc =3D new=20
myclass();<BR>&nbsp;System.out.println("before");<BR>&nbsp;mc.mydll("hell=
o");<BR>&nbsp;&nbsp;System.out.println("After");<BR>&nbsp;}<BR>}<BR></FON=
T></DIV>
<DIV><FONT face=3DArial size=3D2>I have compiled myclass.java. Then =
<STRONG>javah=20
-jni myclass</STRONG> to produce myclass.h file.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><STRONG>Here my VC++ code =
:</STRONG></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>#include "stdafx.h"<BR>#include=20
&lt;c:\jdk1.3\include\jni.h&gt;<BR>#include &lt;stdio.h&gt;<BR>#include=20
"c:\tryal\myclass.h"</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><BR>BOOL APIENTRY DllMain( HANDLE =
hModule,=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
DWORD&nbsp; ul_reason_for_call,=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
LPVOID lpReserved<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
)<BR>{<BR>&nbsp;&nbsp;&nbsp;=20
return TRUE;<BR>}</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><BR>extern "C" JNIEXPORT void JNICALL=20
<BR>Java_ShowMessage_ShowMessage(JNIEnv* env, <BR>jobject, jstring jMsg) =

{<BR>&nbsp; const char* =
msg=3Denv-&gt;GetStringUTFChars(jMsg,0);<BR>&nbsp;=20
printf("Thinking in Java, JNI: %s\n", msg);<BR>&nbsp;=20
env-&gt;ReleaseStringUTFChars(jMsg, msg);<BR>}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I could compile entire dll. Copied =
dll&nbsp;at=20
&nbsp;Winnt\system32 on my machine.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>then i typed following at dos prompt =
:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><STRONG>java =
myclass</STRONG></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><STRONG></STRONG></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><STRONG>This gave me&nbsp; : =
</STRONG></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><STRONG>Exception in thread "main"=20
java.lang.UnsatisfiedLinkError:=20
mydll<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at =
myclass.mydll(Native=20
Method)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at=20
myclass.main(myclass.java:14)<BR></STRONG></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><STRONG>Can u pls solve=20
this??</STRONG></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><STRONG></STRONG></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>thanks</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Bhargavi</DIV></FONT></BODY></HTML>

------=_NextPart_000_000D_01C28B38.4F89B710--