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

Jon Foster jon at jfpossibilities.com
Tue Apr 18 02:42:32 CEST 2017

On 04/15/2017 12:14 PM, fredvs wrote:
> Jon Foster wrote
>> The only thing that console apps need is a terminal emulator.
> Huh, yes, when I re-read my mail, I see directly that this will be the
> problem.
> The "One only library-method used by the Java Class" needs of course a
> terminal to show his output.
> Jon Foster wrote
>> Linux (Android kernel) only runs executables from a file system that
>> allows you to set the "execute" permission
> For Java-native libraries too ?
If I understand your question correctly: No, since the library isn't 
"executed" (in the traditional *nix sense) its "loaded" and used. As you 
stated you need an Android Java (Dalvik) app, which gets executed, and then 
it loads the library and calls the functions in it. But never forget you 
need someway to display stuff... and the normal Pascal methods of providing 
user interaction are not available on Android.

Take this simple program:

program hello;
uses SysUtils;
s: string;
   write('Enter your name: ');
   WriteLn('Hello ', s);

Assuming you made it into a library and write a Dalvik wrapper you still 
need some place for the input to come from and the output to go to. On 
Linux this would be "standard in" and "standard out", attached to a 
terminal somewhere/somehow (VGA adapter, xterm, pipes, ...).

Technically all you need to do this with Android is a compiler for the 
architecture of the Android device (usually ARM) and a terminal app. Once 
compiled you can place the app on an SD card (typically available) then 
launch your terminal app, copy the app from the SD card into "/data/tmp", 
"chmod a+x /data/tmp/myapp" (change "myapp" to the name of yours) and then 
launch it and interact with it via the terminal app.

You have to copy the app to "/data/tmp" as that is usually the only place 
on Android with a Linux file system that all users have access to. You 
can't look in there so you kind of have to fly blind. :-) "Terminal IDE" 
makes this easier, assuming you have a compatible Android version, since it 
provides the Linux file system space, term emulator and easy access.

This was what I thought Paul was looking to do. FreeVision might work 
depending on a number of variables... but I'm not familiar with it. Most 
Android terminal apps would provide some kind of VT100 like emulation so 
you may have to force FreeVision to output for that emulation. If it tries 
to use a "termcap" through normal means it probably will crash.

Jon Foster
JF Possibilities, Inc.
jon at jfpossibilities.com

More information about the fpc-pascal mailing list