Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to run the application fully in the classpath #72

Closed
betanzos opened this issue Mar 29, 2020 · 4 comments · Fixed by #92
Closed

Allow to run the application fully in the classpath #72

betanzos opened this issue Mar 29, 2020 · 4 comments · Fixed by #92

Comments

@betanzos
Copy link
Contributor

I has been develop this cross-platform application skeleton but I have problems to run it with javafx:run because this MOJO always add the javafx's JAR files in the modulepath.

Windows example command executed by javafx:run

> D:\tools\java\adoptopenjdk-11.0.4+11_hotspot\bin\java.exe
	--module-path
		D:\tools\maven-repository\org\openjfx\javafx-base\14\javafx-base-14-linux.jar;
		D:\tools\maven-repository\org\openjfx\javafx-base\14\javafx-base-14-mac.jar;
		D:\tools\maven-repository\org\openjfx\javafx-base\14\javafx-base-14-win.jar;
		D:\tools\maven-repository\org\openjfx\javafx-controls\14\javafx-controls-14-linux.jar;
		D:\tools\maven-repository\org\openjfx\javafx-controls\14\javafx-controls-14-mac.jar;
		D:\tools\maven-repository\org\openjfx\javafx-controls\14\javafx-controls-14-win.jar;
		D:\tools\maven-repository\org\openjfx\javafx-graphics\14\javafx-graphics-14-linux.jar;
		D:\tools\maven-repository\org\openjfx\javafx-graphics\14\javafx-graphics-14-mac.jar;
		D:\tools\maven-repository\org\openjfx\javafx-graphics\14\javafx-graphics-14-win.jar
	--add-modules
		javafx.base,
		javafx.base,
		javafx.base,
		javafx.controls,
		javafx.controls,
		javafx.controls,
		javafx.graphics,
		javafx.graphics,
		javafx.graphics
	-classpath
		C:\Users\Betanzos\Desktop\cross-platform-app-fx\target\classes
	com.betanzos.Main

This may cause some problems due to overlapping modules (duplicated) which are not reloaded. For example, when I run the app in Windows, only the JAR javafx-graphics-14-linux.jar are loaded as javafx.graphics module so Windows libs are missing and the app exits (if I run the app in linux work fine).

We can see the problem if run the app adding the JVM parameter --show-module-resolution (below output exclude all non related modules for simplicity):

...
root javafx.base file:///D:/tools/maven-repository/org/openjfx/javafx-base/14/javafx-base-14-linux.jar
...
root javafx.controls file:///D:/tools/maven-repository/org/openjfx/javafx-controls/14/javafx-controls-14-linux.jar
...
root javafx.graphics file:///D:/tools/maven-repository/org/openjfx/javafx-graphics/14/javafx-graphics-14-linux.jar
...
root javafx.fxml file:///D:/tools/maven-repository/org/openjfx/javafx-fxml/11.0.2/javafx-fxml-11.0.2-win.jar
...
javafx.fxml requires javafx.graphics file:///D:/tools/maven-repository/org/openjfx/javafx-graphics/14/javafx-graphics-14-linux.jar
javafx.fxml requires javafx.base file:///D:/tools/maven-repository/org/openjfx/javafx-base/14/javafx-base-14-linux.jar
javafx.fxml requires java.scripting jrt:/java.scripting
javafx.fxml requires java.xml jrt:/java.xml
...
javafx.graphics requires java.desktop jrt:/java.desktop
javafx.graphics requires javafx.base file:///D:/tools/maven-repository/org/openjfx/javafx-base/14/javafx-base-14-linux.jar
javafx.graphics requires java.xml jrt:/java.xml
javafx.graphics requires jdk.unsupported jrt:/jdk.unsupported
...
javafx.controls requires javafx.base file:///D:/tools/maven-repository/org/openjfx/javafx-base/14/javafx-base-14-linux.jar
javafx.controls requires javafx.graphics file:///D:/tools/maven-repository/org/openjfx/javafx-graphics/14/javafx-graphics-14-linux.jar
...
javafx.base requires java.desktop jrt:/java.desktop
...

Having said that it would be useful to add a way to run the application fully on the classpath.

Windwos command we want to execute with javafx:run

> D:\tools\java\adoptopenjdk-11.0.4+11_hotspot\bin\java.exe
	-classpath
		C:\Users\Betanzos\Desktop\cross-platform-app-fx\target\classes;
		D:\tools\maven-repository\org\openjfx\javafx-base\14\javafx-base-14-linux.jar;
		D:\tools\maven-repository\org\openjfx\javafx-base\14\javafx-base-14-mac.jar;
		D:\tools\maven-repository\org\openjfx\javafx-base\14\javafx-base-14-win.jar;
		D:\tools\maven-repository\org\openjfx\javafx-controls\14\javafx-controls-14-linux.jar;
		D:\tools\maven-repository\org\openjfx\javafx-controls\14\javafx-controls-14-mac.jar;
		D:\tools\maven-repository\org\openjfx\javafx-controls\14\javafx-controls-14-win.jar;
		D:\tools\maven-repository\org\openjfx\javafx-graphics\14\javafx-graphics-14-linux.jar;
		D:\tools\maven-repository\org\openjfx\javafx-graphics\14\javafx-graphics-14-mac.jar;
		D:\tools\maven-repository\org\openjfx\javafx-graphics\14\javafx-graphics-14-win.jar;
		C:\Users\Betanzos\Desktop\cross-platform-app-fx\target\classes
	com.betanzos.Main
@abhinayagarwal
Copy link
Collaborator

when I run the app in Windows, only the JAR javafx-graphics-14-linux.jar are loaded as javafx.graphics module so Windows libs are missing and the app exits (if I run the app in linux work fine).

@betanzos I am trying to wrap my head around this comment. Why would an app running on Windows load linux related jars? Isn't this resolved automatically on Maven resulting in the correct libs being added to the module-path?

@betanzos
Copy link
Contributor Author

betanzos commented Jun 8, 2020

Why would an app running on Windows load linux related jars?

Because in some cases we want to develop, and to distribute, an multiplatform-application (like in my example and in #58) as a fat jar.

But this is just an example. I thing it is a good option to be able to run our app fully in classpath intead of modulepath since there are a huge number of maven artifacts that are incompatible with the Java Module System (some of them widely used).

@abhinayagarwal
Copy link
Collaborator

@betanzos Another question: Why would someone want to use the plugin if they want to run the entire application on classpath?

This can be simply achieved by adding JavaFX jars as dependency and using the maven-exec-plugin to run the application.

@betanzos
Copy link
Contributor Author

betanzos commented Jun 9, 2020

You're right, but for those who are used to working with this plugin with modular JavaFX apps, use it too with non-modular apps could be more natural.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants