How to run ControlsFX sample application using Java 11 and JavaFX 11

DfM :

ControlsFX website says:

If you want to play with the ControlsFX sample application, simply download the ControlsFX release and run the following command on the command prompt (be sure to replace the * with the actual version number of FXSampler and ControlsFX-samples):

java -jar controlsfx-samples-*.jar

I've downloaded ControlsFX 9.0.0 which is said to be for users of Java 9 and later.

When I run java -jar controlsfx-samples-9.0.0.jar I get

Error: Could not find or load main class fxsampler.FXSampler
Caused by: java.lang.NoClassDefFoundError: javafx/application/Application

But that's OK, as according to Run HelloWorld using JavaFX 11 guide, I have to add modules.

So I try java --module-path "C:\Program Files\Java\javafx-sdk-11\lib" --add-modules=javafx.controls -jar controlsfx-samples-9.0.0.jar and I get

Missing JavaFX application class fxsampler.FXSampler

I execute all commands from controlsfx-9.0.0 directory which contains controlsfx-9.0.0.jar, controlsfx-samples-9.0.0.jar and fxsampler-1.0.10.jar.

Output of java -version for me is:

openjdk version "11.0.1" 2018-10-16
OpenJDK Runtime Environment 18.9 (build 11.0.1+13)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode)

Any comments and suggestions are appreciated.
Thanks in advance.

EDIT:
After following Slaw's advice and running java --module-path "C:\Program Files\Java\javafx-sdk-11\lib" --add-modules=javafx.controls,javafx.fxml,javafx.web -jar controlsfx-samples-9.0.0.jar I get

Initialising FXSampler sample scanner...
        Discovering projects...
                Found project 'ControlsFX', with sample base package 'org.controlsfx.samples'
Exception in Application start method
java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.RuntimeException: Exception in Application start method
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
        at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class impl.org.controlsfx.version.VersionChecker
        at org.controlsfx.control.ControlsFXControl.(ControlsFXControl.java:35)
        at org.controlsfx.control.WorldMapView.(WorldMapView.java:93)
        at org.controlsfx.samples.HelloWorldMapView.(HelloWorldMapView.java:55)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
        at java.base/java.lang.Class.newInstance(Class.java:584)
        at fxsampler.util.SampleScanner.discoverSamples(SampleScanner.java:86)
        at fxsampler.FXSampler.start(FXSampler.java:106)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
        at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
        ... 1 more
Exception running application fxsampler.FXSampler
DfM :

Fixed in PR #720. So new Maven artifacts will incorporate the fix.

Full issue history can be seen here.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=83679&siteId=1