[fpc-pascal] fpc code for Java class and Android.

fredvs fiens at hotmail.com
Sat Apr 8 15:21:12 CEST 2017


Hello.

Here a easy way to translate all your fpc applications into Java
applications (class).
The trick is to convert your fpc applications into native java libraries.
It works for fpc console, fpGUI and MSEgui code on Android OS too.

Here we go:

1) In your main application change this:

program myapp;

with this:

library myapp;

2) Change your main procedure:

procedure MainProc; 

with this:

procedure MainProc(PEnv: pointer; Obj: pointer); cdecl;

3) At the end of code (just before end.) add this:

exports
  {Here the only-one exported procedure...}
  MainProc name 'Java_myapp_mainproc';

4) Compile your new java native library. (For Android, compile it for the
same cpu as your Android device).

Ok, now to run your library, create that Java class and save it as
"myapp.java":

public class myapp{

  public static native void mainproc();

  public static void main(String[] args)

  {
  System.loadLibrary("myapp");
  mainproc();
  }
}

And compile it:

# javac myapp.java

Yep, all is done.

To run your Java class+ fpc native Java library, do in console:

# java -Djava.library.path=. myapp

Here video that shows all the process:

https://sites.google.com/site/designerext/fpc_java.mp4

Fre;D









-----
Many thanks ;-)
--
View this message in context: http://free-pascal-general.1045716.n5.nabble.com/fpc-code-for-Java-class-and-Android-tp5728166.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.



More information about the fpc-pascal mailing list