Starting the Harbour virtual machine from Android !!!

Starting the Harbour virtual machine from Android !!!

Postby Antonio Linares » Tue Apr 26, 2011 6:52 am

In order to start the Harbour virtual machine, we need to create a
simple Java class to interface from Java to Harbour (c level):

Code: Select all  Expand view
public class Harbour {
        static {
                System.loadLibrary( "harbour" );
        }

        public native void vmInit( int i );
}
 


Now, for a test, we simply add this code in harbour/src/rtl/adir.prg:

Code: Select all  Expand view
function Main()

return nil

#pragma BEGINDUMP

#include <jni.h>

JNIEXPORT void JNICALL Java_test_test_Harbour_vmInit( JNIEnv * env,
jobject obj, jint i )
{
   hb_vmInit( i );

}

#pragma ENDDUMP
 


where test_test is the name of the package that we have used to
include the Class Harbour in the Android (Java) project.

Then from Android we do:
Code: Select all  Expand view
     Harbour harbour = new Harbour();
     harbour.vmInit( 1 );
 

already tested and working fine :-)

Viktor, it may be convenient if such JINIEXPORT (entry point from Java
to C) could be provided in the Harbour project source code, same as we
have an entry point for Windows, etc.

For more info, examples and full source code for using Harbour with
Android, please visit:
http://code.google.com/p/fivedroid/
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Return to FiveLinux / FiveDroid (Android)

Who is online

Users browsing this forum: No registered users and 5 guests