0

I am trying to install JavaFX and in particular just run this application. I've been using Java for a while and I have to compile from console since IntelliJ just won't load in my laptop. Whenever I try compiling with "javac HelloFX.java" I get a lot of errors and in particular error: package javafx.application does not exist. This is what my java folder looks like

Java Folder

I also already set up a path C:\Program Files\Java\javafx-sdk-18.0.1\lib

I really have no clue as to what I am doing wrong, and the solutions I've been able to find seem rather complex, or use IntelliJ tools. Thank you in advance.

  • Show the command you're using, for [example](https://github.com/openjfx/samples/tree/master/HelloFX/CLI), and any errors; a similar example is cited [here](https://stackoverflow.com/a/71288497/230513). – trashgod May 28 '22 at 19:05
  • Try using a version of the JDK which includes JavaFX, for example Bellsoft Liberica JDK, ensure it is the “full jdk” version. Then it will be much easier to use the command line tools as you won’t need to supply additional module information and paths. – jewelsea May 28 '22 at 20:15

2 Answers2

3

Even if IntelliJ does not work for you, you could still use either Maven or Gradle to build your project which would already simplify things a lot. You should also have a look at the official documentation. https://openjfx.io/openjfx-docs/

mipa
  • 10,369
  • 2
  • 16
  • 35
  • 1
    I'll be sure to try out Maven ty I already looked at the documentation (that's where I got the application and the path from) but It doesn't seem to be working. – Carlos Yeddiel May 28 '22 at 19:04
  • 1
    If you are using Maven then you don’t need to directly call javac as you are doing in your question. Maven will call javac for you (which is *much* easier). – jewelsea May 28 '22 at 20:10
1

There are 4 main steps to check: (There are other ways to do this but this is one way)

  1. Make sure you installed javafx from the marketplace, in case of eclipse it is eclipse marketplace.

  2. Download and unzip the appropriate Java SDK folder for you system from here: https://gluonhq.com/products/javafx/

  3. On your project, configure build path, add a user library, new , then add external JARs, then choose all the .jar files on your Java SDK folder then add that library to your project

  4. Run your project as a normal java application (so that you don't have to search for it later in the configurations) then choose run as, configure the run and you will find an arguments tab, add this to your VM arguments but replace what is inside the double quotations with the file path of your Java SDK lib folder- make sure it's the lib folder, inside the Java SDK. Here is what you will paste: --module-path "\path\to\javafx-sdk-11\lib" --add-modules javafx.controls,javafx.fxml

Powerscore
  • 11
  • 2