on 02-10-2006 5:18 PM
Hello,
I'm trying to call some native code from a MI application on WM2003 SE.
<b>[NOT MI]</b>
1. Created a JAVA wrapper application to call a native DLL (in NWDS, then executing javac, javah to create a header file)
2. Created the native DLL in embedded Visual C++ 4.0
3. Copied the native DLL and the JAVA wrapper app. to a mobile device
4. Started JAVA application (using Jrun from Creme 3.26)
5. Everything worked fine, the native functions were called.
<b>[MI]</b>
1. Added the JAVA wrapper class to a MI project
2. Deployed the MI project to the mobile device
3. When I try to call the native DLL from the servlet, I get an exception:
<i>java.lang.UnsatisfiedLinkError on <method_name> </i>
I think the problem is somewhere in the Tomcat server. I've tried to put the native dll in various directories (\Windows; \MI\bin\native etc.). I've also tried to set up java.library.path in MobileEngine.config:
<i>MI.ClientInstaller.StaticCommandLine=-Of -mi -classpath '%CI_HOME%/MICI.jar' com.sap.ip.mi.ci.ClientInstaller '-home:%CI_HOME%' -Djava.library.path=\windows
</i>
<i>MI.StaticCommandLine=-mi -Of -cf MI/creme_listOfJars.txt com.sap.ip.me.core.Startup '-home:%MI_HOME%' -Djava.library.path=\windows
</i>
Despite trying anything I could think about, I'm still experiencing the problem. Pls., can anyone help? Thanks in advance!
Regards,
Marek
P.S. Which version of the tomcat server is included in MI 2.5? I think it's the 3.3 version, but I'm not sure about this.
<b>JAVA wrapper class:</b>
public class NativeWrapper {
static {
System.loadLibrary("OrwNat");
}
public static native void Func1();
public static native void Func2();
}
<b>Servlet class:</b>
public class MIInfoClass extends AbstractMEHttpServlet implements Constants {
...
public String doHandleEvent(
String eventName,
HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
...
if (eventName.equals(EVENT_NAME_CALL)) {
NativeWrapper.Func1();
nextJSP = TABLEVIEW_JSP;
}
...
hello marek,
try loading your DLL using
System.loadLibrary or
Runtime.getRuntime().loadLibrary
API prior to your invocation.
Please refer to their javadocs for details.
>Which version of the tomcat server is included in MI 2.5?
MI is using 3.2 version of Tomcat.
regards
jo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The problem is not with the library itself. I think it's successfully loaded, because when I try to load some other library (e.g. loadLibrary("ImNotHere")) I get an error:
<i>java.lang.UnsatisfiedLinkError: no ImNotHere in shared library path
</i>
instead of:
<i>java.lang.UnsatisfiedLinkError on <method_name> </i>
So it seems like there is a problem with the method names. However, I don't understand why I'm able to call these methods from standard JAVA code (not MI)
Any ideas?
Thanks in advance!
Message was edited by: Marek Samaj
hello marek,
did you add the path to your library into the environment
variable PATH? if it is not found there, you will get
that UnsatisfiedLinkError.
Was the name you specified in the loadLibrary method the
same name with that of your library? e.g.
public class Jni {
static {
System.loadLibrary("Jni");
}
public native String whoiam();
public static void main(String[] args) {
Jni jni = new Jni();
System.out.println(jni.whoiam());
}
}
header name: Jni.h
so your Jni.dll location should be added into your
PATH env var.
regards
Jo
Hello Jo,
again, thank you very much for your time!
>did you add the path to your library into the environment
variable PATH?
I'm using this code on the Windows Mobile 2003 operating system. I don't know about any standard method to set the environment variables in this operating system. Despite this, I don't think that I have problem with the path. When I try to load some other library that I'm sure it doesn't exist, I get other error text with UnstatisfiedLinkError Exception (pls, see my previous post). Furthermore, I'm not expriencing any problems when using this DLL outside MI...
>Was the name you specified in the loadLibrary method the
same name with that of your library?
No! The name of the method is prefixed with: <i>Java_<className>_<methodName></i> in the library.
SOLVED!!!
The problem was with the method names, good suggestion Jo!
The methods must be prefixed with: Java_<b><package_name></b>_<className>_<methodName>
I had a default package in the notMI JAVA application, so there was no need of a package name in the C++ library.
However, in the MI app there was a package under which were the classes defined. This was the reason of the UnstatisfiedLinkError!
Regards,
Marek
Hi,
I'm with a problem in the DLL generation... I have been passed for this problem with package, on desktop tests, but i solved it... Now i'm trying run the DLL in the PPC 2003, the DLL is load, but the method into it is not found.
Java Code
package br.com.fiscalizacao.arcpad;
public class nativetest{
static {
System.loadLibrary("nativetest");
}
public native String sayHello(String x);
public native String SendScript(String x);
public static void main(String[] argv)
{
nativetest nt = new nativetest();
//Método 1
String x = nt.sayHello("Access to DLL do with success.");
System.out.println(x);
}
}
C Code
JNIEXPORT jstring JNICALL _Java_br_com_fiscalizacao_arcpad_nativetest_sayHello
(JNIEnv *env, jobject thisobject, jstring js)
{
return js;
}
Anyone?
hi Jo.
i`m facing a problem with loading the dll ,
using Creme 4.10
the output i get in jscpout file is
java.lang.Unsatisfiedlinkerror : no Helloworld.dll in
java.library.path
and than the call stack.
i have tried copying it to \windows and in the \windows\creme\bin directory but with same error..
any idea about what can be the problem
thanks in advance
kapil
User | Count |
---|---|
78 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.