Skip to content
Snippets Groups Projects
Commit edc921ef authored by Hallvard Trætteberg's avatar Hallvard Trætteberg
Browse files
parents 66837bae 65dab78e
No related branches found
No related tags found
No related merge requests found
Pipeline #48576 passed with stage
in 2 minutes and 12 seconds
Showing
with 85 additions and 6 deletions
## Installation
### Install Java
#### Download link
https://www.java.com/en/download/
#### [Guide for installing Java Development Kit](https://gitlab.stud.idi.ntnu.no/it1901/course-material/blob/master/howto/get-java.md "Installing Java")
#### Download links
* http://jdk.java.net
* https://www.oracle.com/technetwork/java/javase/downloads/index.html
#### How and why to uninstall older versions of Java
https://www.java.com/en/download/faq/remove_olderversions.xml
......@@ -10,7 +17,7 @@ https://www.java.com/en/download/faq/remove_olderversions.xml
#### Download link
https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
#### For Windows we reccomend Git for Windows
#### For Windows we recommend Git for Windows
https://gitforwindows.org/
### Install Eclipse or Intellij
......
......@@ -5,6 +5,15 @@
To be able to develop in Java one requires a JDK - Java Development Kit. You have to download and properly set up java
For IT1901 either JDK 11 or 12 will do just fine.
Installing manually the jdk has the following steps no matter what operating system you are using:
* download the archive containing the desired release
* extract it
* move it to a meaningful location (depends on the os what is a good location)
* set up environment variables for `JAVA_HOME` and `PATH`
* apply changes if necessary
Note: The examples shown here use filenames as they were for jdk 12.0.2 at the moment of redacting the document. Adjust the filenames and the paths as needed. Depending on your OS version or flavour you might have different text editors and you might need to adjust for that as well.
## Install java
......@@ -83,6 +92,9 @@ Open a terminal window and type
java -version
```
![](images/linux03_check_false.png)
#### 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 +108,11 @@ sudo mkdir /usr/lib/jvm
sudo mv jdk-12.0.2 /usr/lib/jvm/
```
![](images/linux02_extract.png)
![](images/linux04_move.png)
#### Set up the environment variables
create a shell script in /etc/profile.d
......@@ -104,6 +121,9 @@ create a shell script in /etc/profile.d
sudo nano /etc/profile.d/jdk.sh
```
![](images/linux05_env01.png)
add the following lines inside the file and save and close
``` bash
......@@ -112,6 +132,8 @@ export PATH=$PATH:$JAVA_HOME/bin
```
![](images/linux06_env02.png)
apply changes
logout and log back in or run the script you have just created
......@@ -128,7 +150,7 @@ echo $JAVA_HOME
java -version
```
![](images/linux07_check_true.png)
### MacOs
......@@ -140,6 +162,9 @@ Open a terminal window and type
java -version
```
![](images/mac_02_check_false.png)
#### 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 +175,18 @@ Extract the files using the following command
tar xf openjdk-12.0.2_osx-x64_bin.tar.gz
```
![](images/mac_03_extract.png)
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/
```
![](images/mac_04_move.png)
#### Set up the environment variables
......@@ -168,15 +198,29 @@ If the file mentioned does not exist we can create it with the following command
touch ~/.bash_profile
```
![](images/mac_05_env01.png)
We need to export the `JAVA_HOME` variable so we edit the file using
``` bash
edit ~/.bash_profile
```
or
``` bash
nano ~/.bash_profile
```
![](images/mac_06_env02.png)
we add the following line
`export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk-12.0.2/Contents/Home"`
`export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home"`
![](images/mac_08_env03.png)
finally we save the changes and close the file. To apply the changes we need to run the following command
......@@ -184,6 +228,12 @@ finally we save the changes and close the file. To apply the changes we need to
source ~/.bash_profile
```
![](images/mac_07_apply_env.png)
check if everything is in order
![](images/mac_09_check_true.png)
## Using sdkman
......@@ -265,3 +315,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
```
howto/images/12 - java check ok.png

65 KiB | W: | H:

howto/images/12 - java check ok.png

19.3 KiB | W: | H:

howto/images/12 - java check ok.png
howto/images/12 - java check ok.png
howto/images/12 - java check ok.png
howto/images/12 - java check ok.png
  • 2-up
  • Swipe
  • Onion skin
howto/images/linux01_download.png

110 KiB

howto/images/linux02_extract.png

26.7 KiB

howto/images/linux03_check_false.png

52.4 KiB

howto/images/linux03_list.png

39.9 KiB

howto/images/linux04_move.png

50.6 KiB

howto/images/linux05_env01.png

26.8 KiB

howto/images/linux06_env02.png

47.5 KiB

howto/images/linux07_check_true.png

48 KiB

howto/images/mac_01_check_false.png

49.8 KiB

howto/images/mac_02_check_false.png

26.9 KiB

howto/images/mac_03_extract.png

57.5 KiB

howto/images/mac_04_move.png

28.7 KiB

howto/images/mac_05_env01.png

24.1 KiB

howto/images/mac_06_env02.png

25 KiB

howto/images/mac_07_apply_env.png

25.8 KiB

howto/images/mac_08_env03.png

38.1 KiB

howto/images/mac_09_check_true.png

32.9 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment