[fpc-pascal] Integration of fpc/jvm classes in java prorgram

Jonas Maebe jonas at freepascal.org
Sat Apr 18 20:04:17 CEST 2020


On 17/04/2020 10:17, Luca Olivetti wrote:
> I have to integrate in an existing java product a custom functionality.
> This product has a plugin system where you implement some classes,
> (implementing predefined interfaces) and override the methods of the
> such classes/interfaces.
> 
> It also provides some api classes you can call back into and it uses
> java swing for the UI.
> 
> Would it be possible to use the fpc jvm to implement plugins for this
> system?

Yes.

> (i.e. is it easy enough to implement derived classes and call
> into the java api)?

Creating derived classes works the same as in Object Pascal:
type
  tmyclass = class(javaclass)
    ..
  end;

Calling the Java API is also easy, once you create an import unit.
Explanations on how to do that can be found at
https://wiki.freepascal.org/FPC_JVM/Building#Creating_interfaces_for_other_Java_classes

The hard part is that while most high level language features are
available, none of the standard units are (apart from part of the System
unit). This means you will have to write Pascal code against the Java
API for anything non-trivial.

See https://wiki.freepascal.org/FPC_JVM for more information.


Jonas


More information about the fpc-pascal mailing list