4

i want to learn javaFX but online sources only show installation and setup in an IDE like: Netbeans , Eclipse , IntelliJ etc.

but i want to do it without IDE
ie : using only Terminal and a text editor(vim).

what is the steps to set up JavaFX for a projects and run it without any IDE.

JDK version:- 11.0.4
Os :- Parrot OS

rhens
  • 4,791
  • 3
  • 22
  • 38
Saneen K P
  • 303
  • 1
  • 8
  • 1
    Why do you want to do it without IDE ie using only Terminal and a text editor(vim)? It will be difficult for you to compile, execute, debug etc. without an IDE. – Arvind Kumar Avinash Jul 04 '20 at 20:06
  • 5
    Install Java. Download the JavaFX SDK and install that as well (via Gluon or possibly via a package manager). If you don't want to download the SDK then use Maven or Gradle and pull in JavaFX from Maven Central. Use Java from the command line as normal (using a build tool such as Maven or Gradle will significantly simplify things). Configure Vim in whatever way that's accomplished (never used it). – Slaw Jul 04 '20 at 20:10
  • @Slaw I suggest you make an Answer of your Comment, so that it can be accepted. – Basil Bourque Jul 04 '20 at 22:55
  • @Slaw thank you for the answer . i like to write everything on my own just for educational purpose . and about your answer i am already familiar with the steps you mentioned . but i am confused about the location and package and etc where i should install javaFX as importing would cause error if not done correctly i guess. – Saneen K P Jul 05 '20 at 11:50
  • If you download the JavaFX SDK you'd "install" it where you install all your other programs. Then you add it to the `--module-path` when you're compiling and executing your application. If you use Maven or Gradle and download it from Maven Central then the JavaFX dependencies will be cached in each tool's respective local repository. Then the build tools, when configured correctly, will handle setting the command line arguments for you. Note that JavaFX is just like any other (platform-specific) third-party dependency now. – Slaw Jul 05 '20 at 12:25
  • You can just follow a maven tutorialand run it using `mvn javafx:run` or `mvn exec:java -Dexec.mainClass=fully.qualified.MainClass` – dan1st Apr 13 '21 at 15:55

1 Answers1

2
  1. first download your desired version of java i would recommend openjdk-11
    sudo apt install openjdk-11-jdk
  2. download the javaFx from here
  3. set the JAVA_HOME environment variable to the JDK installation directory (this answer would help)
  4. set the PATH_TO_FX environment variable by the same way as above but the path should point to /lib eg: export PATH_TO_FX=path/to/javafx-sdk-11/lib
  5. compile and run your javafx code like this :

javac --module-path $PATH_TO_FX --add-modules javafx.controls [filename].java

java --module-path $PATH_TO_FX --add-modules javafx.controls [filename]

med benzekri
  • 490
  • 6
  • 19