diff --git a/howto/get-java.md b/howto/get-java.md index c2aa8440977b0f7921fcb3c8275e67e032789fbc..9fcfe8ea2db02c9c1dac3a9e7c00983cde02aafe 100644 --- a/howto/get-java.md +++ b/howto/get-java.md @@ -83,6 +83,9 @@ Open a terminal window and type java -version ``` + + + #### Extract downloaded binary After the download finishes you have in the destination folder the `.tar.gz` file with a name like this `openjdk-12.0.2_linux-x64_bin.tar.gz` . @@ -96,6 +99,11 @@ sudo mkdir /usr/lib/jvm sudo mv jdk-12.0.2 /usr/lib/jvm/ ``` + + + + + #### Set up the environment variables create a shell script in /etc/profile.d @@ -104,6 +112,9 @@ create a shell script in /etc/profile.d sudo nano /etc/profile.d/jdk.sh ``` + + + add the following lines inside the file and save and close ``` bash @@ -112,6 +123,8 @@ export PATH=$PATH:$JAVA_HOME/bin ``` + + apply changes logout and log back in or run the script you have just created @@ -128,7 +141,7 @@ echo $JAVA_HOME java -version ``` - + ### MacOs @@ -140,6 +153,9 @@ Open a terminal window and type java -version ``` + + + #### Extract downloaded binary After the download finishes you have in the destination folder the `.tar.gz` file with a name like this `openjdk-12.0.2_osx-x64_bin.tar.gz`. @@ -150,13 +166,18 @@ Extract the files using the following command tar xf openjdk-12.0.2_osx-x64_bin.tar.gz ``` + + + Move the extracted to the folder `/Library/Java/JavaVirtualMachines/` You will need to execute the move with super user privileges in order to put the files in the system folder ``` bash -sudo mv jdk-12.0.2 /Library/Java/JavaVirtualMachines/ +sudo mv jdk-12.0.2.jdk /Library/Java/JavaVirtualMachines/ ``` + + #### Set up the environment variables @@ -168,22 +189,42 @@ If the file mentioned does not exist we can create it with the following command touch ~/.bash_profile ``` + + + We need to export the `JAVA_HOME` variable so we edit the file using ``` bash edit ~/.bash_profile ``` +or + +``` bash +nano ~/.bash_profile +``` + + + we add the following line `export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk-12.0.2/Contents/Home"` + + + finally we save the changes and close the file. To apply the changes we need to run the following command ``` bash source ~/.bash_profile ``` + + + +check if everything is in order + + ## Using sdkman @@ -265,3 +306,25 @@ See more commands on the sdkman.io site 4. download the binary corresponding to your operating system There are more choices for downloads. Typically a .zip or .tar.gz would imply manual setup while the .exe, .deb, .rpm, .dmg will provide some sort of installer support. + +For the .zip or .tar.gz files you need to follow the procedure from above. +.exe (windows) - run and follow the installer prompts +.dmg (mac) - run and follow the installer prompts +.deb (linux) - package format used in Debian and Ubuntu linux distributions + +```bash +sudo dpkg -i ~/Downloads/jdk-12.0.2_linux-x64_bin.deb +``` + +alternative way to install .deb packages is with apt + +```bash +sudo apt install ~/Downloads/jdk-12.0.2_linux-x64_bin.deb +``` +In Ubuntu you can also double click the package and it will open in Software Center where there is an option to install it. + +.rpm (linux) - package format commonly used in Redhat and Mandrake linux distributions + +``` bash +rpm -ivh ~/Downloads/jdk-12.0.2_linux-x64_bin.rpm +```