reveal
reveal copied to clipboard
ClassNotFound: com.sun.javafx.tk.Toolkit
{:clojure.main/message
"Syntax error (ClassNotFoundException) compiling at (vlaaad/reveal/font.clj:1:1).\ncom.sun.javafx.tk.Toolkit\n",
:clojure.main/triage
{:clojure.error/phase :compile-syntax-check,
:clojure.error/line 1,
:clojure.error/column 1,
:clojure.error/source "font.clj",
:clojure.error/path "vlaaad/reveal/font.clj",
:clojure.error/class java.lang.ClassNotFoundException,
:clojure.error/cause "com.sun.javafx.tk.Toolkit"},
:clojure.main/trace
{:via
[{:type clojure.lang.Compiler$CompilerException,
:message "Syntax error compiling at (vlaaad/reveal/font.clj:1:1).",
:data
{:clojure.error/phase :compile-syntax-check,
:clojure.error/line 1,
:clojure.error/column 1,
:clojure.error/source "vlaaad/reveal/font.clj"},
:at [clojure.lang.Compiler load "Compiler.java" 7648]}
{:type java.lang.ClassNotFoundException,
:message "com.sun.javafx.tk.Toolkit",
:at
[java.net.URLClassLoader findClass "URLClassLoader.java" 471]}],
:trace
[[java.net.URLClassLoader findClass "URLClassLoader.java" 471]
[clojure.lang.DynamicClassLoader
findClass
"DynamicClassLoader.java"
69]
[java.lang.ClassLoader loadClass "ClassLoader.java" 588]
[clojure.lang.DynamicClassLoader
loadClass
"DynamicClassLoader.java"
77]
[java.lang.ClassLoader loadClass "ClassLoader.java" 521]
[java.lang.Class forName0 "Class.java" -2]
[java.lang.Class forName "Class.java" 398]
[clojure.lang.RT classForName "RT.java" 2211]
[clojure.lang.RT classForNameNonLoading "RT.java" 2224]
[vlaaad.reveal.font$eval150$loading__6721__auto____151
invoke
"font.clj"
1]
[vlaaad.reveal.font$eval150 invokeStatic "font.clj" 1]
[vlaaad.reveal.font$eval150 invoke "font.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7177]
[clojure.lang.Compiler eval "Compiler.java" 7166]
[clojure.lang.Compiler load "Compiler.java" 7636]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6839 invoke "core.clj" 6126]
[clojure.core$load invokeStatic "core.clj" 6125]
[clojure.core$load doInvoke "core.clj" 6109]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5908]
[clojure.core$load_one invoke "core.clj" 5903]
[clojure.core$load_lib$fn__6780 invoke "core.clj" 5948]
[clojure.core$load_lib invokeStatic "core.clj" 5947]
[clojure.core$load_lib doInvoke "core.clj" 5928]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$load_libs invokeStatic "core.clj" 5985]
[clojure.core$load_libs doInvoke "core.clj" 5969]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$require invokeStatic "core.clj" 6007]
[clojure.core$require doInvoke "core.clj" 6007]
[clojure.lang.RestFn invoke "RestFn.java" 421]
[vlaaad.reveal.stream$eval144$loading__6721__auto____145
invoke
"stream.clj"
1]
[vlaaad.reveal.stream$eval144 invokeStatic "stream.clj" 1]
[vlaaad.reveal.stream$eval144 invoke "stream.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7177]
[clojure.lang.Compiler eval "Compiler.java" 7166]
[clojure.lang.Compiler load "Compiler.java" 7636]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6839 invoke "core.clj" 6126]
[clojure.core$load invokeStatic "core.clj" 6125]
[clojure.core$load doInvoke "core.clj" 6109]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5908]
[clojure.core$load_one invoke "core.clj" 5903]
[clojure.core$load_lib$fn__6780 invoke "core.clj" 5948]
[clojure.core$load_lib invokeStatic "core.clj" 5947]
[clojure.core$load_lib doInvoke "core.clj" 5928]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$load_libs invokeStatic "core.clj" 5985]
[clojure.core$load_libs doInvoke "core.clj" 5969]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$require invokeStatic "core.clj" 6007]
[clojure.core$require doInvoke "core.clj" 6007]
[clojure.lang.RestFn invoke "RestFn.java" 619]
[vlaaad.reveal.prepl$eval138$loading__6721__auto____139
invoke
"prepl.clj"
1]
[vlaaad.reveal.prepl$eval138 invokeStatic "prepl.clj" 1]
[vlaaad.reveal.prepl$eval138 invoke "prepl.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7177]
[clojure.lang.Compiler eval "Compiler.java" 7166]
[clojure.lang.Compiler load "Compiler.java" 7636]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6839 invoke "core.clj" 6126]
[clojure.core$load invokeStatic "core.clj" 6125]
[clojure.core$load doInvoke "core.clj" 6109]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5908]
[clojure.core$load_one invoke "core.clj" 5903]
[clojure.core$load_lib$fn__6780 invoke "core.clj" 5948]
[clojure.core$load_lib invokeStatic "core.clj" 5947]
[clojure.core$load_lib doInvoke "core.clj" 5928]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$load_libs invokeStatic "core.clj" 5985]
[clojure.core$load_libs doInvoke "core.clj" 5969]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$require invokeStatic "core.clj" 6007]
[clojure.main$main_opt invokeStatic "main.clj" 514]
[clojure.main$main_opt invoke "main.clj" 510]
[clojure.main$main invokeStatic "main.clj" 664]
[clojure.main$main doInvoke "main.clj" 616]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.lang.Var applyTo "Var.java" 705]
[clojure.main main "main.java" 40]],
:cause "com.sun.javafx.tk.Toolkit",
:phase :compile-syntax-check}}
Hi! Thanks for the report, I'll have a look.
I can't reproduce it with various JDKs I tried, can you tell me where you obtained your JDK?
Note for self: here is a java -version
you posted on reddit:
openjdk version "11.0.6" 2020-01-14
OpenJDK Runtime Environment (build 11.0.6+10)
OpenJDK 64-Bit Server VM (build 11.0.6+10, mixed mode)
The oracle jdk 13, open jdk 13 don't work neither.
Is com.sun.javafx.tk.Toolkit
built-in with jdk?
No, it's a part of JavaFX library, which should be brought in as an artifact on java 11 and beyond. It's internal, but it has been a part of JavaFX for a long time. Could it be that you have some kind of headless JDK that can't have desktop access?
maybe, It could be. I installed these versions through package manager in Arch Linux, even though it doesn't named as headless
.
I'll post when I have more information.
Greetings!
I have a similar (the same?) issue, even though I use a different Java version. The most important part of the error message highlighted in bold:
Exception in thread "JavaFX Application Thread" java.lang.IllegalAccessError: class vlaaad.reveal.font$fn__220 (in unnamed module @0x71527bdf) cannot access class com.sun.javafx.tk.Toolkit (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.tk to unnamed module @0x71527bdf
at vlaaad.reveal.font$fn__220.invokeStatic(font.clj:26)
The Java I use is 18.0.1:
openjdk version "18.0.1" 2022-04-19
OpenJDK Runtime Environment Zulu18.30+11-CA (build 18.0.1+10)
OpenJDK 64-Bit Server VM Zulu18.30+11-CA (build 18.0.1+10, mixed mode, sharing)
Updated
I switched to Java 1.8 a few minutes ago:
openjdk version "1.8.0_332"
OpenJDK Runtime Environment (Zulu 8.62.0.19-CA-macosx) (build 1.8.0_332-b09)
OpenJDK 64-Bit Server VM (Zulu 8.62.0.19-CA-macosx) (build 25.332-b09, mixed mode)
Running the REPL from the command line works well:
clj -A:reveal
Clojure 1.11.1
user=> (require '[vlaaad.reveal :as r])
nil
user=> (r/tap-log)
nil
user=> (tap> (System/getProperties))
true
user=>
Running the REPL in the same way it should run from the Cursive works too:
clj -A:reveal -m vlaaad.reveal repl
However, it fails to run from Cursive. This is the configuration I have:

The error message I get is
Reflection warning, cljfx/jdk/fx/window.clj:9:3 - call to method setForceIntegerRenderScale on javafx.stage.Window can't be resolved (no such method).
Reflection warning, cljfx/jdk/fx/window.clj:9:3 - call to method setRenderScaleX on javafx.stage.Window can't be resolved (no such method).
Reflection warning, cljfx/jdk/fx/window.clj:9:3 - call to method setRenderScaleY on javafx.stage.Window can't be resolved (no such method).
Syntax error (IllegalArgumentException) compiling . at (cljfx/jdk/platform.clj:12:5).
No matching method startup found taking 1 args for class javafx.application.Platform
It seems something is wrong with Cursive, though I have no clue what.
@manenko After switching the jdk from 11+ to 1.8 or back you need to clear clj cache — either by running it with -Sforce
or by removing .cpcache
directory.
@manenko After switching the jdk from 11+ to 1.8 or back you need to clear clj cache — either by running it with
-Sforce
or by removing.cpcache
directory.
I deleted the .cpcache
but the problem with Cursive is still there. Anyway, It does not seem to be a problem with the REPL. It is either of asdf, Java installation or Cursive. I'll keep trying :-)
The REPL is great, by the way. I was looking for a more comprehensive replacement for clojure.inspector
. One of the requirements is that the alternative must be capable of working with the remote REPLs and reveal
seems to be exactly what I need. I just have to figure out how to make it work with my company's setup :-)
Having the same problem with JDK17 but not with 11.
Tested with clj -Sforce -Sdeps '{:deps {vlaaad/reveal {:mvn/version "1.3.273"}}}' -X vlaaad.reveal/repl
outside of a clojure project.
Error on JDK17 with JavaFX17
Exception in thread "JavaFX Application Thread" java.lang.IllegalAccessError: class vlaaad.reveal.font$fn__280 (in unnamed module @0x48c59476) cannot access class com.sun.javafx.tk.Toolkit (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.tk to unnamed module @0x48c59476
at vlaaad.reveal.font$fn__280.invokeStatic(font.clj:26)
at vlaaad.reveal.font$fn__280.invoke(font.clj:26)
at clojure.lang.Delay.deref(Delay.java:42)
at clojure.core$deref.invokeStatic(core.clj:2337)
at clojure.core$deref.invoke(core.clj:2323)
at vlaaad.reveal.font$line_height.invokeStatic(font.clj:33)
at vlaaad.reveal.font$line_height.invokePrim(font.clj)
at vlaaad.reveal.style$fn__329.invokeStatic(style.clj:175)
at vlaaad.reveal.style$fn__329.invoke(style.clj:33)
at clojure.lang.Delay.deref(Delay.java:42)
at clojure.core$deref.invokeStatic(core.clj:2337)
at clojure.core$deref.invoke(core.clj:2323)
at vlaaad.reveal.ui$window.invokeStatic(ui.clj:596)
at vlaaad.reveal.ui$window.invoke(ui.clj:563)
at clojure.lang.AFn.applyToHelper(AFn.java:154)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.lang.Var.applyTo(Var.java:705)
at clojure.core$apply.invokeStatic(core.clj:669)
at clojure.core$apply.invoke(core.clj:662)
at cljfx.lifecycle$wrap_map_desc$fn__3941.invoke(lifecycle.clj:446)
at cljfx.lifecycle$eval3651$fn__3673$G__3638__3682.invoke(lifecycle.clj:17)
at cljfx.renderer$render_component.invokeStatic(renderer.clj:57)
at cljfx.renderer$render_component.invoke(renderer.clj:47)
at cljfx.renderer$create$fn__5070.invoke(renderer.clj:77)
at cljfx.renderer$perform_render$fn__5021.invoke(renderer.clj:23)
at cljfx.renderer$perform_render.invokeStatic(renderer.clj:22)
at cljfx.renderer$perform_render.invoke(renderer.clj:14)
at cljfx.renderer$request_render$fn__5047$fn__5051.invoke(renderer.clj:44)
at cljfx.renderer$request_render$fn__5047.invoke(renderer.clj:44)
at clojure.lang.AFn.run(AFn.java:22)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:290)
at java.base/java.lang.Thread.run(Thread.java:833)
Java 17 java -version
:
openjdk version "17.0.3" 2022-04-19
OpenJDK Runtime Environment (build 17.0.3+7-nixos)
OpenJDK 64-Bit Server VM (build 17.0.3+7-nixos, mixed mode, sharing)
cat $JAVA_HOME/lib/javafx.properties
javafx.version=17.0.0.1-internal
javafx.runtime.version=17.0.0.1-internal+0-2022-07-13-074400
javafx.runtime.build=0
Java 11:
openjdk version "11.0.15" 2022-04-19
OpenJDK Runtime Environment (build 11.0.15+0-adhoc..source)
OpenJDK 64-Bit Server VM (build 11.0.15+0-adhoc..source, mixed mode)
cat $JAVA_HOME/lib/javafx.properties
javafx.version=11.0.3-internal
javafx.runtime.version=11.0.3-internal+0-2022-05-07-094045
javafx.runtime.build=0
Any way I can help debug this?
@lycheese "module javafx.graphics does not export com.sun.javafx.tk to unnamed module @0x48c59476" probably means jdk 17 is more restrictive about reflective access to internal classes. You'll probably need to add something like --add-opens=???/???=ALL-UNNAMED to the jvm args. I'm not sure what exactly should be there, I'll check when I return from the vacation
@lycheese "module javafx.graphics does not export com.sun.javafx.tk to unnamed module @0x48c59476" probably means jdk 17 is more restrictive about reflective access to internal classes. You'll probably need to add something like --add-opens=???/???=ALL-UNNAMED to the jvm args. I'm not sure what exactly should be there, I'll check when I return from the vacation
I think it should be -J--add-opens javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED
(taken form this SO question) but it complains that modules need to be specified and I have been unable to get that working so far.
Changing -J--add-opens javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED
to -J--add-opens -Jjavafx.graphics/com.sun.javafx.tk=ALL-UNNAMED
did it.
Edit:
Full working command for javafx17:
clj -J--add-opens -Jjavafx.graphics/com.sun.javafx.tk=ALL-UNNAMED -Sdeps '{:deps {vlaaad/reveal {:mvn/version "1.3.273"}}}' -X vlaaad.reveal/repl
If using :jvm-opts
in deps.edn
the two parts need to be two separate strings as well:
{,,,
:jvm-opts ["--add-opens" "javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED"]
,,,}