-1

I'm trying to run a JavaFX app through CMD but I can't make it work. What I did so far:

1) followed this guide and added the new environment variable (the JavaFX folder is in the desktop, does this make a difference?)

2) Tried to compile with javac --module-path %PATH_TO_FX% --add-modules javafx.controls HelloFX.java The HelloFX app is here

But I get an error saying "Module not found: JavaFX.controls". Does somebody know how can I solve that? (Also Javafx.controls.jar is in the JavaFX's lib folder).

1

3 Answers 3

1

OK I found a solution: if instead of %PATH_TO_FX% I put the full path to the JavaFX's lib folder (as an example: "C:\Desktop\JavaFX12.0.1\lib") being careful to put the path in the quotation marks, it works.

I don't understand why this happens so if somebody knows I would be thankful if they could share.

Sign up to request clarification or add additional context in comments.

1 Comment

Did you do this: set PATH_TO_FX="C:\Desktop\JavaFX12.0.1\lib" in the first place?
0

Lorenzo's solution works for me, the path of javafx lib goes in compile and then run command instead of %PATH_TO_FX% with "path".

Practically:

for compile(with my javafx lib path):

javac --module-path "C:\Program Files\javafx-sdk-14\lib" --add-modules javafx.controls HelloFX.java

for run:

java --module-path "C:\Program Files\javafx-sdk-14\lib" --add-modules javafx.controls HelloFX

Comments

0

My solution on Mac was:

Compile:

javac --module-path Java/javafx-sdk-18.0.1/lib --add-modules javafx.controls fileName.java 

Run:

java --module-path Java/javafx-sdk-18.0.1/lib --add-modules javafx.controls fileName 

JavaFx path: Desktop/Java/javafx-sdk-18.0.1/lib. (As the Java folder is on the Desktop and I have previously configured my directory to the Desktop, the path began with the folder name without the simple slash </>.)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.