As we already know up to JDK-10 JavaFX used to be a part of JDK but with the release of JDK-11, JavaFX is to be included separately .
For doing that we need to provide VM argument for JavaFX like this:-
--module-path "C:\javafx-sdk-11.0.1\lib" --add-modules=javafx.controls,javafx.fxml
Up to this point every thing is ok but when we are finally creating a JAR file for distribution then a message is appearing like this:
VM arguments will not be part of the runnable JAR. Arguments can be passed on the command line when launching the JAR
Therefore now JAR file is not able to open the application.
Now please help me by suggesting some way out so that user can open application just by clicking on JAR icon as it used to be earlier.
EDIT
After applying the solution provided by openjfx.io (section non-modular projects), I am able to generate a Standalone Jar File with JavaFX.
Now I want to add some local dependencies like pdfbox
and Sqlite
:
sqlite =C:\sqlite-jdbc-3.6.20.1.jar
pdfbox=C:\pdfbox-app-2.0.10.jar
I am doing following steps:
Step-1
cd eclipse-workspace2018\test101
Step-2
set PATH_TO_FX="C:\javafx-sdk-11.0.1\lib"
Step-3
dir /s /b src\*.java > sources.txt & \
javac --module-path %PATH_TO_FX% --add-modules=javafx.controls \
-d out @sources.txt & del sources.txt
Step-4
cd out & jar xf "%PATH_TO_FX%\javafx.base.jar" & \
jar xf "%PATH_TO_FX%\javafx.graphics.jar" & \
jar xf "%PATH_TO_FX%\javafx.controls.jar" & \
cd ..
copy "%PATH_TO_FX%\..\bin\prism*.dll" out & \
copy "%PATH_TO_FX%\..\bin\javafx*.dll" out & \
copy "%PATH_TO_FX%\..\bin\glass.dll" out & \
copy "%PATH_TO_FX%\..\bin\decora_sse.dll" out
del out\META-INF\MANIFEST.MF & del out\module-info.class
mkdir libs
jar --create --file=libs/index101.jar \
--main-class=test101.Launcher -C out .
java -jar libs\index101.jar
Kindly modify my steps for adding above mentioned two dependencies pdfBox & sqlite.