0

I am new to JavaFX. I have a project as the below structure.

<MyCompany-App>
     <src>
        <CoreUtils>
           Constants.java
           Constants2.java
        <CoreFramework>
           VersionControl.java
           Utils.java
        <MyCompanyApp>
           Main.java
           LaunchLogin.java
        <Logging>
           Logging.java
        <Utils>
           DBcon.java
     <lib>
        javafx.controls.jar
        javafx.fxml.jar
        javafx.web.jar

lib directory has all the other dependent 3rd party jars as well.

With this set up, developers are able to compile the source code to a JAR file using IntelliJ IDE.

But, I am trying to generate the jar file using command line as below.

$javac --module-path "<Path to project>\lib" --add-modules javafx.controls,javafx.fxml "<Path to    Project>\LaunchLogin.java"

I am facing error saying package not found.

**error: package CoreFramework does not exist
import CoreFramework.Utils;**

Below are the some of the lines in LaunchLogin.java

package MyCompanyApp;

import CoreFramework.VersionControl;
import CoreFramework.Constants;
import CoreFramework.Localization;
import CoreFramework.Utils;

Can someone help me how to compile this source to a JAR?

Tried to compile it using CLI

Slaw
  • 37,820
  • 8
  • 53
  • 80
  • 1
    Honestly, I'd use a build tool (e.g. [Maven](https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html)), also see [JavaFX specific instructions](https://openjfx.io/openjfx-docs/#maven) it will be easier. – jewelsea Jun 28 '23 at 19:25
  • 1
    I agree with jewelsea: You should be using a build tool (Maven or Gradle). That said, I believe you're missing arguments like `--source-path ` in your `javac` command. Also note that without a `-d ` argument, the class files will be put next to their originating source files (i.e., in your `src` directory, which is probably not a great place for _class files_ to be). – Slaw Jun 28 '23 at 20:20
  • 1
    Also, just an FYI, don't expect that you can just compile to a jar file and share the jar file easily (if that is something you want to do). To share a jar file with others, it is necessary they have a compatible Java runtime installed. And, that the dependent modules, e.g. the JavaFX runtime, are either included in the runtime or provided with your distribution. And your application is executed with those modules added to the module system and placed on the module path for the application execution. An alternative can be a zipped jlink image generated by the javafx maven plugin. – jewelsea Jun 28 '23 at 21:06
  • 1
    The example examined [here](https://stackoverflow.com/a/76276885/230513) can be built entirely on the command line, linked via `jlink` and run. – trashgod Jun 28 '23 at 22:26

0 Answers0