[EMAIL PROTECTED] wrote on 2007-07-03 23:56:31:
> I have another problem about bundle and JNI.
> Now, in my java bundle code as follows, this java bundle need to use
> JNI to get some data from C/C++ program via for the function:
> getPressedKeyCode() which is defined in getPressedCode.c .
>
>
//--------------------------------------------------------------------------------
> //
> //-------------------------- getPressedCode.java---------------------//
> package tmp.getpressedcode;
>
> import org.osgi.framework.BundleActivator ;
> import org.osgi.framework.BundleContext;
>
> public class getPressedCode implements BundleActivator
> {
> static
> {
> //load library according to the rule of JNI technology
> System.loadLibrary ("getPressedCode"); //load library
> }
>
> //this function would be defined in C/C++ file
> public native static void getPressedKeyCode();
>
> public void start(BundleContext context) throws Exception
> {
> getPressedKeyCode();
> }
> public void stop(BundleContext context) throws Exception
> {
> }
> }
> //-------------------
> end-------------------------------------------------------------//
>
> I removed the first sentence about package and use JNI mechanism to
> creat the related lib and link to it properlly, and I have tred to
> use this link lib via another test file, and find this JNI
> getPressedKeyCode() function is ok to run.
I don't think you can remove the package statement to run javah. The
package name must be built into the native method name produced by javah.
>
> However, when I build this getPressedCode.java into myBundle.jar
> file, find it can't work after installing in knopflerfish osgi framwork.
> So, how to handl this bundle which need to use JNI mechanism?
> Many thanks to you!
>
> Jerry_______________________________________________
> OSGi Developer Mail List
> [email protected]
> http://www2.osgi.org/mailman/listinfo/osgi-dev
--
BJ Hargrave
Senior Technical Staff Member, IBM
OSGi Fellow and CTO of the OSGi Alliance
[EMAIL PROTECTED]
office: +1 386 848 1781
mobile: +1 386 848 3788
_______________________________________________
OSGi Developer Mail List
[email protected]
http://www2.osgi.org/mailman/listinfo/osgi-dev