java_leaflet icon indicating copy to clipboard operation
java_leaflet copied to clipboard

Not able to build the library

Open Asquator opened this issue 1 year ago • 4 comments

Hello, For some reason I can by no means use the library in a Maven JavaFX Intellij-IDEA project. Tried both building the jar and importing it as a module, and installing it via maven. Regarding the last option, the package is not included in maven-central, and installation from jitpack.io produces an error. With importing the jar directly and after setting the module-path in maven-javafx-plug, I still can't use the functionality provided by jlmap (the project compiles, but in runtime an error is produced):

Exception in Application start method
java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:119)
	at java.base/java.lang.reflect.Method.invoke(Method.java:578)
	at [email protected]/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:465)
	at [email protected]/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:364)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:578)
	at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1081)
Caused by: java.lang.RuntimeException: Exception in Application start method
	at [email protected]/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:901)
	at [email protected]/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:196)
	at java.base/java.lang.Thread.run(Thread.java:1589)
Caused by: java.lang.IllegalAccessError: superclass access check failed: class com.sun.javafx.sg.prism.web.NGWebView (in unnamed module @0x8ce7cb7) cannot access class com.sun.javafx.sg.prism.NGGroup (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.sg.prism to unnamed module @0x8ce7cb7
	at java.base/java.lang.ClassLoader.defineClass1(Native Method)
	at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1013)
	at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
	at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
	at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
	at [email protected]/io.github.makbn.jlmap.JLMapView.<init>(JLMapView.java:57)
	at com.example.rf/com.example.rf.HelloApplication.start(HelloApplication.java:21)
	at [email protected]/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:847)
	at [email protected]/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:484)
	at [email protected]/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at [email protected]/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
	at [email protected]/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
	at [email protected]/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
	at [email protected]/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:316)
	... 1 more
Exception running application com.example.rf.HelloApplication

Configuration options (maven plugin)

<options>
    <option>--add-exports javafx.web/com.sun.javafx.webkit=ALL-UNNAMED</option>
    <option>--add-modules=javafx.graphics,javafx.web</option>
</options>

Dependencies I tried to add

<dependency>
            <groupId>io.github.makbn</groupId>
            <artifactId>jlmap</artifactId>
            <version>1.9.4</version>
</dependency>
        
<dependency>
            <groupId>com.github.makbn</groupId>
            <artifactId>java_leaflet</artifactId>
            <version>1.9.4</version>
</dependency>

Desktop (please complete the following information): Linux Intellij-IDEA

What is a recommended way to install the library?

Thank you!

Asquator avatar Dec 01 '23 21:12 Asquator

UPD: Could build the module using the jitpack dependency

<dependency>
            <groupId>com.github.makbn</groupId>
            <artifactId>java_leaflet</artifactId>
            <version>1.9.4</version>
</dependency>

Still getting a runtime error

Asquator avatar Dec 01 '23 22:12 Asquator

Hi @Asquator Can you please add your JDK version? For different versions we need to import different modules you may need to check different combinations of options. Based on the exception message you may need to add these modules too:

--[JAVAFX_PATH]/lib --add-modules=javafx.swing,javafx.graphics,javafx.fxml,javafx.media,javafx.web --add-reads javafx.graphics=ALL-UNNAMED --add-opens javafx.controls/com.sun.javafx.charts=ALL-UNNAMED --add-opens javafx.graphics/com.sun.javafx.iio=ALL-UNNAMED --add-opens javafx.graphics/com.sun.javafx.iio.common=ALL-UNNAMED --add-opens javafx.graphics/com.sun.javafx.css=ALL-UNNAMED --add-opens javafx.base/com.sun.javafx.runtime=ALL-UNNAMED

About importing the library, please visit this page, I just checked and I was able to install the package: https://github.com/makbn/java_leaflet/packages/1942280

makbn avatar Dec 19 '23 19:12 makbn

Thank you for your response. I was able to import the library using maven and git packages. I experience some trouble with setting the correct exports to jlmap module:

java.lang.IllegalAccessError: class io.github.makbn.jlmap.JLMapView (in module jlmap) cannot access class com.sun.javafx.webkit.WebConsoleListener (in module javafx.web) because module javafx.web does not export com.sun.javafx.webkit to module jlmap
	at [email protected]/io.github.makbn.jlmap.JLMapView.initialize(JLMapView.java:102)
	at [email protected]/io.github.makbn.jlmap.JLMapView.<init>(JLMapView.java:59)
	at [email protected]/io.github.makbn.jlmap.JLMapView$JLMapViewBuilder.build(JLMapView.java:48)
	at rfinder/view.Leaflet.start(Leaflet.java:46)

Do I have to know the exact path to JavaFX? I use a modular Intellij project and JavaFX is installed from maven. I also can't access the package com.sun.javafx.webkit.

Probably not related to the library, but I'm not experienced with odd module dependencies : \

Asquator avatar Feb 07 '24 09:02 Asquator

Yes, you need to have the JavaFX SDK locally and pass it as the program argument. In my case for example:

--module-path /Library/Java/javafx-sdk-19.0.2.1/lib

Please keep this issue updated, it may help others resolve their issue as well. I also had a difficult time figuring it out.

makbn avatar Feb 08 '24 22:02 makbn

@Asquator I removed the code dependency to WebConsoleListener as part of code improvement for the next round of development. It is probably too late but if you still need this change you can check the early version here: https://github.com/makbn/java_leaflet/tree/dev/1.9.4_add_jl_web_engine

makbn avatar Sep 16 '24 09:09 makbn