8

We recently migrated from java 8 to openJdk11. Now I am trying to test my application on windows and ubuntu with using openJdk installed on both OS. I'm able to run it on ubuntu. But same is not executing in windows10 with java11.Error_Message:

enter image description here

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(Unknown Source)
Dominique
  • 16,450
  • 15
  • 56
  • 112
anupm
  • 81
  • 1
  • 1
  • 5
  • Edit your question and post how you run your app, your command line options, and your JDK/JavaFX SDK versions, so we can help you. – José Pereda Jan 01 '19 at 12:48
  • Okay. So i have a question. I'm now able to run JavaFX on windows. You know problem was with the JavaFX jar renaming!!. Actually I was building my project on linux and i see that there were 2 jars of each category. one is javafx-base-11.jar and another one javafx-base-11-linux.jar . When i copied these jars to my classpath in windows it was not taking these jars. So i tried to build my project in windows and there i found jars appended with -winn.jar. So my doubt is how it is like that/ These jars are completely different? If i rename -linux with -win it will not work. – anupm Jan 02 '19 at 09:35
  • 1
    Each platform has different jars, with the proper native libraries (.so for linux, .dll for windows), so you can't use one jar on a different platform. You have to use a different JavaFX SDK and you have to distribute a different solution for each platform. See https://openjfx.io/openjfx-docs/ – José Pereda Jan 02 '19 at 09:41
  • 1
    So you are telling that javaFX jars are now platform dependent? Then how we will achieve platform independent?? If i build my application in windows then I cannot run it on linux and vice-versa. Isn't it bad? I compared 2 jars (javafx-graphics-11-win.jar and javafx-graphics-11-linux.jar) files and found that these 2 are different. Is there any other approach to use graphics jar from other 3rd party libraries? – anupm Jan 02 '19 at 11:41
  • 4
    Exactly, JavaFX jars are platform dependent, because some of them bundle native libraries for the given platform, like `javafx-graphics-11-.jar`. You can do distribution for each platform (via `jlink` or `jpackage`), at the end you rely on a VM that is specific of that platform. However, you can still do a fat jar bundling all the jars and native libraries into one. See https://openjfx.io/openjfx-docs/#modular (section non-modular project). – José Pereda Jan 02 '19 at 13:28

2 Answers2

5

It is possible that JDK, which you have installed on your Windows system, doesn't include JavaFX and you should install it externally.

Read more here: Where can I get pre-built JavaFX libraries for OpenJDK (Windows) or https://stackoverflow.com/a/19529820 or Javafx: No toolkit found exception .

jsosnowski
  • 1,560
  • 3
  • 26
  • 56
  • My application runs on ubuntu 18 with no error. I have all javafx*.jar files in my classpath. If it runs on ubuntu with same configuration why not here? Do i have to do extra configuration for windows? I downloaded JavaFX sdk using the link you provided above. Could you please tell me how to configure this path? – anupm Jan 02 '19 at 06:18
-4

I am not sure how the differnences between Linux and Windows come into place, but in general com.sun.javafx.tk.Toolkitis not accesible anymore since Java 9. So the behaviour on Windows throwing an exception is correct, and you need to find another solution for whatever you are using theToolkit-class for.

Mirko Fetter
  • 186
  • 1
  • 13