Skip to content

Instantly share code, notes, and snippets.

@bigos
Created September 4, 2018 20:16
Show Gist options
  • Save bigos/e01f6e27a822634ae7ba0f5116089a2a to your computer and use it in GitHub Desktop.
Save bigos/e01f6e27a822634ae7ba0f5116089a2a to your computer and use it in GitHub Desktop.
Java 8 and Netbeans

Java

Assumptions

This write-up assumes Ubuntu 18.04 or similar, with OpenJDK installed

links

jacek@jacek-ixtreme-M5850:~/Desktop$ ls -al /usr/bin/java
lrwxrwxrwx 1 root root 22 Jul  9 20:09 /usr/bin/java -> /etc/alternatives/java

jacek@jacek-ixtreme-M5850:~/Desktop$ ls -al /etc/alternatives/java
lrwxrwxrwx 1 root root 43 Jul  9 20:09 /etc/alternatives/java -> /usr/lib/jvm/java-11-openjdk-amd64/bin/java

Install Oracle java

Inspired by the following but without using PPA. https://medium.com/coderscorner/installing-oracle-java-8-in-ubuntu-16-10-845507b13343

select java 8 version and download it

https://www.oracle.com/technetwork/java/javase/downloads/index.html

That will result in a file like this ~/Downloads/jdk-8u181-linux-x64.tar.gz

copy and decompress java

jacek@jacek-ixtreme-M5850:~/Desktop$ cd /usr/lib/jvm/

jacek@jacek-ixtreme-M5850:/usr/lib/jvm$ sudo cp ~/Downloads/jdk-8u181-linux-x64.tar.gz .

jacek@jacek-ixtreme-M5850:/usr/lib/jvm$ ls
default-java               java-11-openjdk-amd64
java-1.11.0-openjdk-amd64  jdk-8u181-linux-x64.tar.gz

jacek@jacek-ixtreme-M5850:/usr/lib/jvm$ sudo tar -xvzf ./jdk-8u181-linux-x64.tar.gz

jacek@jacek-ixtreme-M5850:/usr/lib/jvm$ ls
default-java               java-11-openjdk-amd64  jdk-8u181-linux-x64.tar.gz
java-1.11.0-openjdk-amd64  jdk1.8.0_181

jacek@jacek-ixtreme-M5850:/usr/lib/jvm$ sudo rm ./jdk-8u181-linux-x64.tar.gz

Use alternatives with new java

jacek@jacek-ixtreme-M5850:/usr/lib/jvm$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.0_181/bin/java 2

jacek@jacek-ixtreme-M5850:/usr/lib/jvm$ sudo update-alternatives  --list java
/usr/lib/jvm/java-11-openjdk-amd64/bin/java
/usr/lib/jvm/jdk1.8.0_181/bin/java

jacek@jacek-ixtreme-M5850:/usr/lib/jvm$ sudo update-alternatives  --config java
and select the version you need

jacek@jacek-ixtreme-M5850:/usr/lib/jvm$ java -version

Set JAVA_HOME environment variable

edit the environment

sudo nano /etc/environment

and add the following line

JAVA_HOME="/usr/lib/jvm/jdk1.8.0_181"

Netbeans

Go to this page and click Download https://netbeans.org/

At the time of writing it has sent me to: https://netbeans.apache.org/download/nb90/nb90.html

that has let me to download a zip file.

Uncompressing the file and going to the bin directory lets you run netbeans.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment