Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Mudassir
Posts: 209
Registered: ‎11-08-2008
My Device: Not Specified

net.rim.vm.MissingNativeError + using native method + KNI

[ Edited ]

I used these three classes. It build perfectly but giving net.rim.vm.MissingNativeError at run time at the line where native method is called.

 I want to access this native method. I read in J2ME forums that KNI helps the use of native function.

Please help....

 

/* Hello.java */
import rayman.test.
*;

public class Hello {
        
public static void main(String [] args) {
                KNITest t
=new KNITest();
                t.println(
"Hello KVM ! " + t.nativeTest(1,2));//------> giving error here at run time :smileysad:
        }
}

 

 

/* rayman/test/KNITest.java */
package rayman.test;

public class KNITest {
        
public void println(String s) {
                System.
out.println(s);
        }
        
public static native int nativeTest(int i, int j);
}

 

 

/* nativeTest.c */
#include 
<kni.h>
#include 
<stdio.h>

KNIEXPORT KNI_RETURNTYPE_INT Java_rayman_test_KNITest_nativeTest() {
        jint i1 
= KNI_GetParameterAsInt(1);
        jint i2 
= KNI_GetParameterAsInt(2);
        printf(
"in function Java_rayman_test_KNITest_nativeTest() ");
        KNI_ReturnInt(i1
+i2);
}

Thanks and Regards
Please use plain text.
Developer
simon_hain
Posts: 15,806
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: net.rim.vm.MissingNativeError + using native method + KVI

no native support on blackberry
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
Mudassir
Posts: 209
Registered: ‎11-08-2008
My Device: Not Specified

Re: net.rim.vm.MissingNativeError + using native method + KNI

[ Edited ]

Thanks Simon,

I know ...

But then why native keyword is given?  

And if it is so then it has no right to compile even.

And if its possible in J2ME then why not in Blackberry.

Thanks and Regards
Please use plain text.