Announcing EA builds of standalone JavaFX SDK

Michael Paus mp at jugs.org
Wed May 9 11:39:06 UTC 2018


Hi,
I investigated the issue of using the standalone JavaFX SDK inside of an 
IDE (Eclipse and IntelliJ) a little bit further. For this purpose I used 
a simple single-class JavaFX program (actually the one which Johan used 
too).

I started with Eclipse, created a simple Java project, added the JFX 
jars to the module path and added the --add-modules command to the 
runtime configuration. The result is: this works at compile time but not 
at runtime.

Then I tried the same with IntelliJ. (I have to admit though that I have 
never seriously used IntelliJ before.) I created the project, added the 
dependencies and configured the runtime. The result is: the same error 
as in Eclipse.

The advantage of IntelliJ though is that it directly shows you the 
command line which was created to launch the application. The problem 
seems to be that IntelliJ (in the same way as Eclipse) just puts the 
JavaFX dependencies on the classpath and not on the module path. The 
only way I found to fix this was to add a module-info.java to the project.

module projavafx.helloearthrise.ui {
     requires javafx.graphics;
     requires javafx.controls;
     exports projavafx.helloearthrise.ui;
}

After that you don't need the --add-modules command anymore.

After adding this the setup immediately worked in IntelliJ. In Eclipse 
however the program could now be launched and there was no error or 
warning but the program just hangs and does not show anything on the 
screen. By looking at the generated command line via "ps -ef | grep 
java" I found that Eclipse is adding this option "-XstartOnFirstThread" 
which makes the program hang. There is a switch in the Eclipse runtime 
configuration dialog, which is selected by default, and which causes 
Eclipse to use this option when it thinks it is launched with SWT. This 
is caused by the fact that I have created a library (like Nir suggested) 
into which I put all jars of the JavaFX SDK, also the javafx-swt.jar one 
although it is not needed here. This has never been a problem before the 
split between JDK and JFX. This problem can be fixed by either switching 
off the startOnFirstThread option in the runtime configuration or by 
just not adding the javafx-swt.jar.

So, my conclusion for the moment is that you can only use the split 
JDK/JFX in Eclipse/IntelliJ when your main project has a 
module-info.java. This may be a problem if you are not yet ready or 
willing to modularize your application.

If somebody knows a trick to get around this limitation I'd be happy to 
here about it.

Michael


Am 08.05.18 um 14:39 schrieb Michael Paus:
> Am 08.05.18 um 14:27 schrieb Tom Schindl:
>> [...]
>>
>>> 3. How do you properly configure an Eclipse (the latest 4.7.3a) project
>>> to use this module path. Adding the OpenJDK was no problem but how do
>>> you add the module path for JavaFX? I failed on that.
>>>
>> You just open the Java Build Path-Properties-Page on the project and add
>> the external jars, not?
>>
>> Tom
>
> That's one of the ways I tried it but ...
>
> 1. is that the intended way of doing it? On the command line you just 
> specify a single folder.
>
> 2. I did this and it resolved all dependencies at compile time but I 
> got an exception at runtime
>
> Error occurred during initialization of boot layer
> java.lang.module.FindException: Module javafx.fxml not found
>
> although I also added
>
> --add-modules=javafx.fxml,javafx.controls,javafx.web,javafx.media
>
> as VM arguments.
>



More information about the openjfx-dev mailing list