Since I bought a MacBook Pro, I built a JavaFX environment.
Download the file from the Official Site and then install it. Detailed instructions are on the site.
JavaFX
Download the SDK from the download page of Official Site. I unzipped that file this time under / Library / Java / JavaVirtualMachines /
.
Even in this state, for example, if you compile
$ javac --module-path /Library/Java/JavaVirtualMachines/javafx-sdk-13.0.2/lib --add-modules=javafx.controls,javafx.fxml *.java
You can do it with. But it's too long, so let's make it easier to use.
First, put the PATH in / Library / Java / JavaVirtualMachines / javafx-sdk-13.0.2 / lib
on the way.
You need to edit the config file to get it in your PATH. Since this time is zsh, edit .zshrc
.
~/.zshrc
export PATH_TO_FX=/Library/Java/JavaVirtualMachines/javafx-sdk-13.0.2/lib
I added the top line to the bottom. Then restart the terminal or
$ source ~/.zshrc
Can be reflected by executing on the terminal. Whether or not the PATH is in
$ echo $PATH_TO_FX
You can check whether the execution result of is in the specified location. If you do so far,
$ javac --module-path $PATH_TO_FX --add-modules=javafx.controls,javafx.fxml,javafx.media *.java
You will be able to run it with.
It's still long so I'll wrap it. For that purpose, first prepare a directory called $ HOME / bin
, and put it in ~ / .zshrc
to put it in the PATH.
~/.zshrc
export PATH="$PATH:$HOME/bin"
Add the above line.
After that, create two files, jfxc
and jfx
, in the corresponding directory.
$HOME/bin/jfxc
#!/bin/sh
javac --module-path $PATH_TO_FX --add-modules=javafx.controls,javafx.fxml,javafx.media $@
$HOME/bin/jfxc
#!/bin/sh
java --module-path $PATH_TO_FX --add-modules=javafx.controls,javafx.fxml,javafx.media $@
Write each as above and set the authority.
$sudo chmod 755 jfxc
$sudo chmod 755 jfx
If you reflect it at the end, you will be able to execute it.
$ source ~/.zshrc
compile
$ jfxc *.java
Run
$ jfx (file name)
January 26 Audioclip was not available, so some edits were made.
I referred to the following article. Running JavaFX on Java 11 How to pass PATH on mac Create your own Mac command in 1 minute copy and paste
Recommended Posts