I'm using Java 11 and JavaFX 11. So my JavaFX project contains module-info.class with lines like:

module checker {
requires javafx.fxml;
requires javafx.controls;
requires TextInputProgram; // this is external jar that I added in modular JavaFX project
opens sample;
exports sample; // package of program
}

And I want to build artifacts to get jar including external jar and javafx program via Java 11 following this tutorial.

The problem is:
when I'm writting the command:

dir /s /b src\*.java > sources.txt & javac --module-path %PATH_TO_FX% -d mods/checker @sources.txt & del sources.txt

or

dir /s /b src\*.java > sources.txt & javac --module-path %PATH_TO_FX_MODS% -d mods/checker @sources.txt & del sources.txt

I'm getting:

D:\IdeaProject\checker>dir /s /b src\*.java > sources.txt & javac --module-path %PATH_TO_FX_MODS% -d mods/checker @sources.txt & del sources.txt
requires TextInputProgram;
^
1 error

Before it I set two paths succesfully:

set PATH_TO_FX="path\to\javafx-sdk-12.0.2\lib"
set PATH_TO_FX_MODS="path\to\javafx-jmods-12.0.2"


Can someone explain how to get Jar that will include JavaFX program and external jar using Java 11?

Aug 8, 2019 in Java 3,735 views
Hey @invzbl3 check If you are using the correct version of java and JavaFX version that you have set the path to. Are you using java 11 and JavaFX 11? but i see your path has been set to point to JavaFX12.
Hey @Sirajul. I specified own versions by the same principle:
openjfx-11.0.2_windows-x64_bin-jmods
openjfx-11.0.2_windows-x64_bin-sdk

The problem is that module isn't found for external jar which I don't know how correctly to set as module to include in final executable jar. I added this external jar as lib in Project Structure, in module-info.class, but still cmd is complaining about it.

I guess you should try this. Add the path to the external jar file here( instead of putting it in a lib ) in this particular operation in the same way as you have specified the JavaFX path.

D:\IdeaProject\checker>dir /s /b src\*.java > sources.txt & javac --module-path %PATH_TO_FX_MODS% -d mods/checker @sources.txt & del sources.txt

you might find this helpful! Check this out:

Here they have directly added the external dependency jar (logic-1.0-sanpshot.jar) using the CLI instead of the conventional way! Have a look: https://dzone.com/articles/javafx-on-jdk-11

Thanks, Karan! It's actually good example.

How can I add new elements to an Array in Java

String[] source = new String[] { "a", ...READ MORE

How to import a jar file in Eclipse?

Click on File > Import. The Import ...READ MORE

From Java 1.5 you can use the String.format method. ...READ MORE

What is the correct way to add external Jars to IntelliJ IDEA Project?

Adding custom JAR files to the EAR project Copy the custom JAR to the ...READ MORE

You can refer the below code if ...READ MORE

Retrieving the path of a running jar file

Its quite simple. Try using the below ...READ MORE

How to run the JAR files in windows?

Following are the steps to run the ...READ MORE