rladstaetter
Posts: 11
Joined: Fri May 06, 2022 1:15 pm

Configure Java Product with Module Path

Hi,

I'm using Advanced Installer 19.4.

I hava a java app which uses JDK17 and JavaFX. For this reason i need to supply some special parameters to the java command:

Code: Select all

 
 -p path/to/modules --add-modules ... --add-exports ... --add-opens ...
If I don't supply those parameters and i try to start the application via the generated shortcut, no error message appears. In fact nothing seems to happen then.

If I supply those parameters as "Virtual Machine parameters" and try to start the app I get an error dialog which says:

"JNI Exception: failed to create the Java VM, Unknown reason"

Of course I can start my app happily from the command line (which contains my custom VM parameters).

what can I do?
Catalin
Posts: 6721
Joined: Wed Jun 13, 2018 7:49 am

Re: Configure Java Product with Module Path

Hello and welcome to our forums,

Unfortunately, I can not say for sure why that happens.

Is the issue happening only when you launch your Java application through the shortcut, or the same happens if you go to the installation folder and launch it from there?

If possible, could you please forward me the following resources:

- a copy of your .AIP file

- a download link for your setup

by e-mail at support at advancedinstaller dot com, so I can further investigate this?

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
rladstaetter
Posts: 11
Joined: Fri May 06, 2022 1:15 pm

Re: Configure Java Product with Module Path

Hello again! I want to pick up this topic again.

I'm using a fairly new version of advanced installer (19.8.x)

I "think" the reason for this problem is that advanced installer java launcher can't parse arguments to the jre with two dashes, for example:

Code: Select all

--add-exports javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED
or any other argument with '

Code: Select all

--
' in front of it I'm afraid.

My current workaround is to use a jre which contains the javafx classes. Azul provides such builds for example. See https://www.azul.com/downloads/?package=jdk

Without the parameters the launcher just starts the java process and there you go.

Maybe this is enough to reproduce the issue?
rladstaetter
Posts: 11
Joined: Fri May 06, 2022 1:15 pm

Re: Configure Java Product with Module Path

Sorry, didn't reply to your questions:
Is the issue happening only when you launch your Java application through the shortcut, or the same happens if you go to the installation folder and launch it from there?
It is the same. The problem is that the launcher just exits with an error message.
Catalin
Posts: 6721
Joined: Wed Jun 13, 2018 7:49 am

Re: Configure Java Product with Module Path

Hello,

I have run a few tests on my end, but I'm afraid I was not able to reproduce the behavior you described.

Truth be told, I'm no Java expert, so that might be a reason why.

If possible, please forward me the following resources:

- a copy of your .AIP file

- a download link for the setup

- some details about the application and, if needed, what prerequisites I should download in order to reproduce this. Additionally, it would be great if you could give me some details about the workaround as well.

by email at support at advancedinstaller dot com so I can run some tests and further investigate this on our end.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
rladstaetter
Posts: 11
Joined: Fri May 06, 2022 1:15 pm

Re: Configure Java Product with Module Path

Ok I'll try to set up a simple example.

Off topic: is there a way to configure this board to send a mail if somebody answers the question? :roll:
Catalin
Posts: 6721
Joined: Wed Jun 13, 2018 7:49 am

Re: Configure Java Product with Module Path

Hello,
Ok I'll try to set up a simple example.
Sure thing!
Off topic: is there a way to configure this board to send a mail if somebody answers the question?
Yes, there is.

First of all, you should "Subscribe" to this thread:
Screenshot_10.png
Screenshot_10.png (43.27 KiB) Viewed 18447 times
Then, you should enable the email option for the "subscribed" threads:
Screenshot_9.png
Screenshot_9.png (121.65 KiB) Viewed 18447 times
(by clicking the bell icon)

Hope this helps!

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
rladstaetter
Posts: 11
Joined: Fri May 06, 2022 1:15 pm

Re: Configure Java Product with Module Path

I just sent an email to your support team. Hope we'll find a solution together!
Catalin
Posts: 6721
Joined: Wed Jun 13, 2018 7:49 am

Re: Configure Java Product with Module Path

Thank you for providing the resources!

I will followup on this thread once I will be done investigating.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
rladstaetter
Posts: 11
Joined: Fri May 06, 2022 1:15 pm

Re: Configure Java Product with Module Path

I have solved this issue for me now by not using the java module path at all. I created an example project here:

https://github.com/rladstaetter/javafx- ... er-example

the trick is to launch the JavaFX application without using the module path. So far this seems to work, but I'm afraid this way of doing things is not how it should be. (?)

As far as I can tell the problem with the module path and advanced installer's exe launcher is a real one and needs a solution. Java applications will be modularized in the future, maybe the classpath way will even be deprecated and removed from future jdks ... :?
Catalin
Posts: 6721
Joined: Wed Jun 13, 2018 7:49 am

Re: Configure Java Product with Module Path

Hello,

I have followed up with our customer over the email for this, but in case anyone else will be stumbling upon this issue in the future - the problem was how the parameters were passed to the JVM, e.g.:

the user was passing them like this:

Code: Select all

--module-path jfx/ --add-modules javafx.controls,javafx.fxml --add-exports javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED
while they should have been passed like this:

Code: Select all

--module-path=jfx/ --add-modules=javafx.controls,javafx.fxml --add-exports=javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED
Additionally, if you want to launch the executable through a shortcut, please make sure you check the "Set product folder as current" from the "Java" page --> your product --> "Settings" tab.
Screenshot_12.png
Screenshot_12.png (39.23 KiB) Viewed 17598 times

Hope this helps!

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
LeeTAI
Posts: 1
Joined: Wed May 01, 2024 9:29 pm

Re: Configure Java Product with Module Path

I tired using the example

Code: Select all

--module-path=jfx/ --add-modules=javafx.controls,javafx.fxml --add-exports=javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED
But I am still getting an error

"JNI Exception: failed to create the Java VM, Unknown reason"

This happens even when running the application directly from the exe (there is no shortcut a this point). I suspect it is because I have not correctly added the JavaFX libraries (jar's and dll's). I'm using OpenJDK21.0.2 and JavaFX21.0.3.

Could someone show how the added JavaFX and how the --module-path=jfx/ correctly references it.
Catalin
Posts: 6721
Joined: Wed Jun 13, 2018 7:49 am

Re: Configure Java Product with Module Path

Hello and welcome to our forums,

First of all, please accept my apologies for such a delayed reply - we had several days off due to the Orthodox Easter and your thread somehow got lost between the others.

I'm afraid I can not say for sure why this is happening. If possible, could you please share with me, by email at support at advancedinstaller dot com the following resources:

- a copy of the AIP file

- a download link for the setup

so I can run some tests on my end and further investigate this issue?

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”