Change OpenJDK to Oracle JDK in openSUSE

Published on March 18, 2017 by Daniel Lanza

 opensuse  java

When installing openSUSE, OpenJDK is installed by default. This tutorial will explain how to change to Oracle JDK.

dalanz@linux-geij:~> java -version
openjdk version "1.8.0_121"
OpenJDK Runtime Environment (IcedTea 3.3.0) (suse-8.1-x86_64)
OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)


You will need the following:


dalanz@linux-geij:~> tar -xf jdk-8u121-linux-x64.tar.gz
dalanz@linux-geij:~> sudo chown -R root:root jdk1.8.0_121
dalanz@linux-geij:~> sudo mkdir -p /usr/local/java
dalanz@linux-geij:~> sudo mv jdk1.8.0_121 /usr/local/java
dalanz@linux-geij:~> sudo vim /etc/profile

export JAVA_HOME
export JRE_HOME
export PATH
dalanz@linux-geij:~> sudo update-alternatives --install /usr/bin/java java /usr/local/java/jdk1.8.0_121/bin/java 1
dalanz@linux-geij:~> sudo update-alternatives --install /usr/bin/javac javac /usr/local/java/jdk1.8.0_121/bin/javac 1
dalanz@linux-geij:~> sudo update-alternatives --config java
There are 3 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                       Priority   Status
* 0            /usr/lib64/jvm/jre-1.8.0-openjdk/bin/java   1805      auto mode
  1            /usr/lib64/jvm/jre-1.7.0-openjdk/bin/java   1705      manual mode
  2            /usr/lib64/jvm/jre-1.8.0-openjdk/bin/java   1805      manual mode
  3            /usr/local/java/jdk1.8.0_121/bin/java       1         manual mode

Press <enter> to keep the current choice[*], or type selection number: 3
update-alternatives: using /usr/local/java/jdk1.8.0_121/bin/java to provide /usr/bin/java (java) in manual mode
dalanz@linux-geij:~> sudo update-alternatives --config javac
There is only one alternative in link group javac (providing /usr/bin/javac): /usr/local/java/jdk1.8.0_121
dalanz@linux-geij:~> source /etc/profile
dalanz@linux-geij:~> java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
comments powered by Disqus

See also

Share transient folder in openSUSE with VirtualBox

This tutorial will explain how to share a host holder into your guest virtual machine. Requirements You will need the following: An openSUSE virtual machine with VirtualBox (Check this link Steps Make transient folder Mount folder Copy and paste files Make transient folder Go to share folder settings and create a new transient folder. Create a new transient folder Give the name to the transient folder New transient folder created It is important to remember the transient folder name.

Read more

How to install openSUSE Leap 42.2 in VirtualBox

This tutorial will explain how to install openSUSE 42.2 Leap in VirtualBox. Requirements You will need the following: VirtualBox openSUSE Leap 42.2 ISO file Steps Preparing the virtual machine Installing openSUSE Post-installation tasks Preparing the virtual machine Open VirtualBox and create a new virtual machine. Select Linux type and openSUSE version. New openSUSE virtual machine Select the amount of memory RAM. The recommendation is 4096 MB (4 GB).

Read more

How to get parameters from XML Properties File

Parameters are read from XML properties file and printed on console. XML Properties File The content of XML Properties File is the following: <?xml version="1.0"?> <properties> <name>Daniel</name> <lastName>Lanza</lastName> <age>29</age> </properties> And the file is located in the desktop: /Users/dalanz/Desktop/person.xml User Java class package com.dalanz.file; import; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.w3c.dom.NodeList; public class ReadPropertiesXML { private File fileSource; public ReadPropertiesXML (File fileSource) { this.fileSource = fileSource; } public String getProperty(String key) { try { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.

Read more