Java Environment Setup
JDK and JRE Setup
JRE not needed for Version > 10
Download Java LTS (Java 8, Java 11, …)
- Oracle JDK 11
- Amazon Correto 11
- Zulu (includes JavaFX auto in JDK11)
Intellij (>2019.1) comes with bundled JDK which includes JavaFX
Java Path Variable Setup
Windows
Go to “Advanced System Settings”:
Go to “Environment Variable”
Add New System Variable named “JAVA_HOME” where you have installed your JDK
Edit Path in System Variable and add the location where “javac.exe” is located
Linux
Check if Java is installed
javac --version
Else install from debian Packages or APT
JAVA_HOME Setup using
export JAVA_HOME= /usr/java/jdk1.7.0_05/
PATH Setup using
export PATH=${PATH}:${JAVA_HOME}/bin
Select which Java Version to use
sudo update-alternatives --config java
IntelliJ Setup
IntelliJ Idea Community Edition: Just Download and Install.
IntelliJ Idea Ultimate Edition: for free,
-
Open JetBrains Account
-
Apply Now for students, Use your BUET email to verify
-
Checkout Licence Page
-
Download IntelliJ Ultimate
-
Install and Run. You’ll be asked for Licence or 14 days trial. Log in with your account and Use IntelliJ Idea Ultimate for free
You have to apply for renewal of your licence every year, you will get an E-mail 14 days before expiration
Configure JDK with IntelliJ:
Go to Structure for New Projects
Select New JDK if there isn’t one
Intellij (>2019.1) comes with bundled JDK which includes JavaFX
And Select the directory where you installed JDK.
You’re ready to go…
Java Exporting Executable Files
Go to: File > Project Structure > Artifacts
Add + Jar > From Modules with Dependencies… > Select Main Class
Go to Build > Build Artifacts, It will create a new Jar File
To run .jar Files:
java -jar my_jar.jar
To run .jar with JAVA_FX Dependencies:
java --module-path PATH_TO_JAVAFX/lib --add-modules=javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.swing,javafx.web --add-opens javafx.base/com.sun.javafx.runtime=ALL-UNNAMED --add-opens javafx.controls/com.sun.javafx.scene.control.behavior=ALL-UNNAMED --add-opens javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED --add-opens javafx.base/com.sun.javafx.binding=ALL-UNNAMED --add-opens javafx.base/com.sun.javafx.event=ALL-UNNAMED --add-opens javafx.graphics/com.sun.javafx.stage=ALL-UNNAMED -jar messenger-client-gui.jar