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

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

Fixed in PR #720. So new Maven artifacts will incorporate the fix.
Full issue history can be seen here.

Related

kaptDebugKotlin crashes when building with Java Version 11 or higher

I'm getting an IllegalStateException/NoClassDefFoundError when trying to run the command ./gradlew :data:test on my project (https://github.com/guger/MoneyBook). This error does occur when I'm using a Java Version higher than 11. I'm not able to use the jdk bundled into the IDE, since robolectric requires Java 9 or higher, when testing against Android Q and Java 9 does not work as it provides it's version string in a format which is not recognized by robolectric.
java.lang.IllegalStateException: failed to analyze: java.lang.NoClassDefFoundError: com/sun/tools/javac/file/BaseFileObject
at org.jetbrains.kotlin.analyzer.AnalysisResult.throwIfError(AnalysisResult.kt:56)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:182)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:164)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:54)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:84)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:42)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:104)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1558)
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:567)
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:689)
at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:389)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:835) Caused by: java.lang.NoClassDefFoundError: com/sun/tools/javac/file/BaseFileObject
at org.jetbrains.kotlin.kapt3.base.javac.KaptJavaFileManager.shouldBeFiltered(KaptJavaFileManager.kt:69)
at org.jetbrains.kotlin.kapt3.base.javac.KaptJavaFileManager.list(KaptJavaFileManager.kt:49)
at jdk.compiler/com.sun.tools.javac.code.ClassFinder.list(ClassFinder.java:737)
at jdk.compiler/com.sun.tools.javac.code.ClassFinder.scanUserPaths(ClassFinder.java:674)
at jdk.compiler/com.sun.tools.javac.code.ClassFinder.fillIn(ClassFinder.java:554)
at jdk.compiler/com.sun.tools.javac.code.ClassFinder.complete(ClassFinder.java:299)
at jdk.compiler/com.sun.tools.javac.code.Symbol.complete(Symbol.java:642)
at jdk.compiler/com.sun.tools.javac.code.Symbol$PackageSymbol.members(Symbol.java:1131)
at jdk.compiler/com.sun.tools.javac.code.Symtab.listPackageModules(Symtab.java:834)
at jdk.compiler/com.sun.tools.javac.comp.Enter.visitTopLevel(Enter.java:345)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:535)
at jdk.compiler/com.sun.tools.javac.comp.Enter.classEnter(Enter.java:286)
at jdk.compiler/com.sun.tools.javac.comp.Enter.classEnter(Enter.java:301)
at jdk.compiler/com.sun.tools.javac.comp.Enter.complete(Enter.java:577)
at jdk.compiler/com.sun.tools.javac.comp.Enter.main(Enter.java:561)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:1066)
at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing(annotationProcessing.kt:66)
at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing$default(annotationProcessing.kt:35)
at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.runAnnotationProcessing(Kapt3Extension.kt:230)
at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.analysisCompleted(Kapt3Extension.kt:188)
at org.jetbrains.kotlin.kapt3.ClasspathBasedKapt3Extension.analysisCompleted(Kapt3Extension.kt:99)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM$analyzeFilesWithJavaIntegration$2.invoke(TopDownAnalyzerFacadeForJVM.kt:96)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:106)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:81)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:555)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:82)
at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:107)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:546)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:177)
... 23 more Caused by: java.lang.ClassNotFoundException: com.sun.tools.javac.file.BaseFileObject
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:436)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 52 more
Does anyone experience a similar behaviour when running Android Projects on Java 11/12/13?
I had a similar issue recently regarding to JDK9.
I used this library which solved the problem:
"com.github.pengrad:jdk9-deps:1.0"
Unfortunately, this is due to the lacking support of JDK 13 in Gradle 5.x.
Gradle 6.0 will support Java 13 (https://docs.gradle.org/6.0/release-notes.html).
Until then, there's no other possibility than waiting.

JavaFX Project running in Eclipse but not in Intellij Idea [duplicate]

This question already has answers here:
IntelliJ can't recognize JavaFX 11 with OpenJDK 11
(7 answers)
Closed 4 years ago.
I'm running IntelliJ IDEA Ultimate 2018.2.5 with JDK 11.0.1 and JavaFX 11 from OpenJFX. I know it's a common error and I tried many of the proposed fixes but nothing works.
No matter which JavaFX project I try to run I get the error:
Error: JavaFX runtime components are missing, and are required to run this application
If I add the following to the VM options
--module-path="C:\Program Files\Java\javafx-sdk-11\lib" --add-modules=javafx.controls
I get these errors:
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.IllegalAccessError: class com.sun.javafx.fxml.FXMLLoaderHelper (in unnamed module #0x5fce9dc5) cannot access class com.sun.javafx.util.Utils (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.util to unnamed module #0x5fce9dc5
at com.sun.javafx.fxml.FXMLLoaderHelper.<clinit>(FXMLLoaderHelper.java:38)
at javafx.fxml.FXMLLoader.<clinit>(FXMLLoader.java:2056)
at sample.Main.start(Main.java:13)
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 sample.Main
I tried reinstalling without any luck. I have also tried to change
getClass().getResource(...) to getClass().getClassLoader().getResource(...) or to something like Parent root = FXMLLoader.load(getClass().getResource("/sample.fxml")); but still doesn't work.
There are similar questions like this or this other one.
Before JavaFX 11, whenever you were calling something JavaFX related, you had all the javafx modules available within the SDK.
But now you have to include the modules/dependencies you need.
Your error says that you are using FXML but it can't be resolved, but you have just added the javafx.controls module:
--add-modules=javafx.controls
As you can see in the JavaDoc the javafx.controls module depends on javafx.graphics and java.base, but none of those modules includes the FXML classes.
If you need FXML classes like the FXMLLoader, you need to include javafx.fxml module:
--module-path="C:\Program Files\Java\javafx-sdk-11\lib" \
--add-modules=javafx.controls,javafx.fxml
The same will apply if you need media or webkit, those have their own modules.

AWS Ubuntu java.lang.ClassNotFoundException: Jama.Matrix

I am trying to run a mutation clustering algorithm described in
https://tinyheero.github.io/2015/08/26/TrAp.html
Running java -jar TrApWithDependencies.jar --text figure1.txt works fine on my laptop running windows 10, but not on AWS ubuntu. I would like to run it on my AWS instance because the algorithm is very RAM hungry and will run out of memory for input data with 50 or more rows.
Running it on Ubuntu Server 18.04 LTS gives me the following error. I believe the key issue is with Jama.Matrix
Exception in thread "main" 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 org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.NoClassDefFoundError: Jama/Matrix
at klugerlab.trap.data.Solution.fitClones(Solution.java:703)
at klugerlab.trap.algo.MinimalClonesSolver.processTemplate(MinimalClonesSolver.java:168)
at klugerlab.trap.algo.MinimalClonesSolver.completeSolutions(MinimalClonesSolver.java:204)
at klugerlab.trap.algo.MinimalClonesSolver.runSolver(MinimalClonesSolver.java:250)
at klugerlab.trap.algo.Solver.run(Solver.java:229)
at klugerlab.trap.algo.Job.run(Job.java:97)
at klugerlab.trap.TrApMain.main(TrApMain.java:120)
... 5 more
Caused by: java.lang.ClassNotFoundException: Jama.Matrix
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 12 more
I do not have access to the source code, only the .jar file.

Run jar file get java.lang.SecurityException: Prohibited package name: java.sql

I compiled the jar file from eclipse (package required lib...), and then when I run it, it gives me the SecurityException: Prohibited package name: java.sql, which doesn't happen when I run code inside eclipse.
I see a lot of people point out the issue might caused by naming one of the package as "java.*", but I double-checked that there is no package that is named as "java.{somthing}".
Here is full error trace:
Exception in thread "main" 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:564)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.SecurityException: Prohibited package name: java.sql
at java.base/java.lang.ClassLoader.preDefineClass(ClassLoader.java:889)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1005)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:545)
at java.base/java.net.URLClassLoader.access$100(URLClassLoader.java:83)
at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:453)
at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:447)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:446)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:563)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
at com.fasterxml.jackson.databind.ser.std.StdJdkSerializers.all(StdJdkSerializers.java:55)
at com.fasterxml.jackson.databind.ser.BasicSerializerFactory.<clinit>(BasicSerializerFactory.java:93)
... 12 more
OS: MacOS Mojave 10.14.2;
Java Version: 9.0.4;
Java(TM) SE Runtime Environment (build 9.0.4+11);
Eclipse Version: Oxygen.2 Release (4.7.2)
P.S. I didn't use mysql or any other sql driver.
Edit:
When I run the code inside eclipse, it works perfectly.
Thank you for your help!
Select Extract required libaries while setting the library handling option in Jar generator. :)

Opening .jar file on mac using JDK 11 fails with RuntimeException

I am trying to open a .jar file (https://github.com/ptrckbnck/SQLChecker/releases) on my MAC Mojave 10.14 , I need it for my university course.
What I did:
installed java OpenJDK 11 as suggested here https://solarianprogrammer.com/2018/09/28/installing-openjdk-macos/
java -version
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)
But when I run java -jar SQLChecker-1.0.jar I keep on getting the following exception:
Graphics Device initialization failed for : es2, sw
Error initializing QuantumRenderer: no suitable pipeline found
java.lang.RuntimeException: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
at com.sun.javafx.tk.quantum.QuantumRenderer.getInstance(QuantumRenderer.java:280)
at com.sun.javafx.tk.quantum.QuantumToolkit.init(QuantumToolkit.java:222)
at com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:260)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:267)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:158)
at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:658)
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:678)
at 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.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:94)
at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:124)
... 1 more
Exception in thread "main" java.lang.RuntimeException: No toolkit found
at com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:272)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:267)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:158)
at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:658)
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:678)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
at java.base/java.lang.Thread.run(Thread.java:834)
I have read related thread Migration to JDK 11 + JavaFX 11 giving RuntimeException and downloaded also JavaFX 11, namely JavaFX Mac OS X SDK from here https://gluonhq.com/products/javafx/. I also run the following code:
export PATH_TO_FX=my/path/to/javafx-sdk-11/lib
and run HelloWorld test using JavaFX 11 as described here https://openjfx.io/openjfx-docs/. Everything worked fine but did not solve my original problem.
As was suggested by #Drimux in the related thread some libraries are missing in the OpenJDK distribution. He sad that those probably are libprism_es2.dylib, libprism_sw.dylib, libglass.dylib, libjavafx_font.dylib. So I copied those files from the javafx-sdk-11.0.1/lib into /Library/Java/JavaVirtualMachine/jdk-11.0.1.jdk/Contents/Home/lib and tried to run my .jar file again. Got new exception:
GLFactory.static - Platform: Mac OS X - not available: com.sun.prism.es2.MacGLFactory
java.lang.ClassNotFoundException: com.sun.prism.es2.MacGLFactory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:315)
at com.sun.prism.es2.GLFactory$FactoryLoader.run(GLFactory.java:108)
at com.sun.prism.es2.GLFactory$FactoryLoader.run(GLFactory.java:100)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at com.sun.prism.es2.GLFactory.<clinit>(GLFactory.java:97)
at com.sun.prism.es2.ES2Pipeline.<clinit>(ES2Pipeline.java:76)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:315)
at com.sun.prism.GraphicsPipeline.createPipeline(GraphicsPipeline.java:187)
at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:91)
at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:124)
at java.base/java.lang.Thread.run(Thread.java:834)
java.lang.ClassNotFoundException: com.sun.glass.ui.mac.MacPlatformFactory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:315)
at com.sun.glass.ui.PlatformFactory.getPlatformFactory(PlatformFactory.java:42)
at com.sun.glass.ui.Application.run(Application.java:144)
at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:258)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:269)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:158)
at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:658)
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:678)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
at java.base/java.lang.Thread.run(Thread.java:834)
Failed to load Glass factory class
Exception in thread "main" java.lang.NullPointerException
at com.sun.glass.ui.Application.run(Application.java:144)
at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:258)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:269)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:158)
at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:658)
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:678)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
at java.base/java.lang.Thread.run(Thread.java:834)
This didn't fix the problem. If you need more information please request.
What else should I try?
If you have downloaded the jar from the first test release, when running it like:
java -jar SQLChecker-1.0.jar
you will get the posted exception.
As a first easy fix, if you have downloaded JavaFX 11 SDK, run this instead:
java --module-path /path-to/javafx-sdk-11/lib --add-modules javafx.controls,javafx.fxml -jar SQLChecker-1.0.jar
You can read about why you need those VM arguments here.
In any case, you shouldn't copy the native files from the JavaFX SDK to the JDK.
New releases
But there are two more new releases of SQLChecker.
If you try the last one:
java -jar SQLChecker-1.0.3.jar
that will work fine, without adding those extra arguments.
So what has changed?
They are distributing a fat Jar with the Maven shade plugin, and in order to work on JavaFX 11 on any platform, you need to include not only the jars, but also the native libraries.
As you can see, in this commit, by including the classifier tag for javafx.graphics, they added the required native libraries for Windows, Linux and Mac, as it has been also stated in this question.
If you want to know more about how to create a fat jar, see this doc.

Categories

Resources