I´m currently evaluating possibilities of mixing delphi and java together.
The idea is as followed :
Delphi Client shows and display GUI (in legacy software) and can interact with a nonvisual java plugin. The Javaplugin is resposible to communicate to a REST-Server.
I´ve written a simple Host in Delphi which loads a nonvisual plugin from java.
When i try to QueryInterface it returns nil. My guess is either I´m missing something or java plugins has to be designed differently. I just dont find the missing clue within the documentation.
To access plugin’s custom interface methods this plugin should be first imported into the host application. This can be done via a button in the solution explorer’s header.
so you need to import java plugin with IDE wizard ( IDE → Tools → Hydra → Import Interfaces from Java module).
After this correspondent code for executing of java method will be created.
can you check, how your plugin is imported in Visual studio, pls?
correctly or also gives some errors?
Do you have JAVA_HOME system variable that references to openjdk folder?
Try to install 32bit jdk too - Delphi IDE is 32 bit and it can’t use 64 bit dll from 32bit process.
after import from java module was generated, you can switch to 64bit jdk again
can you check, how your plugin is imported in Visual studio, pls?
correctly or also gives some errors?
Since we don´t use Visual Studio at work ive installed a Trial to verify it.
I reinstalled Hydra in order to install the Visual Studio integration.
The Results are as followed:
Do you have JAVA_HOME system variable that references to openjdk folder?
Yes it seems to be correct. I´ve using Eclipse JEE Build 09 2019…
I don´t have any issues with Java at all, just with the plugin import from hydra.
Try to install 32bit jdk too - Delphi IDE is 32 bit and it can’t use 64 bit dll from 32bit process.
after import from java module was generated, you can switch to 64bit jdk again
This is a very difficult solution. Java has not been delivered as 32-Bit version since 8.231 (thats the highest version i found).
They are only release 64-Bit solutions. If i would need to switch my Envirements each time i import a new interface this can be a time consuming task (atleast in the first
phases of development). Delivering plugins based on an old runtime also might cause security problems for our customers.
The most interesting part is also : I can run the java based hydra plugin. I can perform the start() task without any issues. I just cant import interfaces.
For testing purpose i switched to Java 8.221 32-Bit and the import itself worked but once i want to compile it, it says : Exception RestClient_Import.pas(35): E2035 Not enough actual parameters.
Self.JVM.Reflection.CallObjectMethod(Self.InstanceID, lmethodId) requires a third param.
Sorry for the inconvenience this caused. The reason for this issue is that 32-bit process (RAD Studio or Visual Studio, that is still 32-bit) cannot load 64-bit JVM dll into process.
We will figure something out regarding this (most probably we will just start a command line tool as a separate 64-bit process under the hood).
There is no need to develop something against old JVM. It is (was) used only once to perform the import process and to generate the wrapper code. The plugin itself can work on the modern JVM version.
I tested the change with params and it worked. Its still time consuming to switch java version each time but as antonk described there is a requirement for a solution.
From consumer view i would love a small tool where you just link your jar file as input, select .NET or Java as output and a directory where to drop the code and it generates Files for you without the requirement of an IDE-Integration.
From my perspective i can adance further for now. Thanks for your fast service!
I just thought i share some wisdom i obtained recently. This still not means there is no need for a 64-Bit Java wrapper but it can help for now as workaround to resolve Issues.
You can get 32\64 Bit OpenJDK through https://adoptopenjdk.net/.
I installed x86 version as Hotspot and x64 as OpenJ version (same not possible through their installshieldshield kit). I can run Eclipse Version: 2019-09 R (4.13.0) without any issues. as Systemenvirement i used C:\Program Files (x86)\AdoptOpenJDK\jdk-13.0.2.8-hotspot.
Now it seems Eclipse takes x64 to run java and allow me to build .jar files. Delphi on the other side takes x86 version and i can import java written plugins. So far it looks doable as workaround but there is no 100% safety it will work in all aspects. Still testing… still researching.