Hot questions for Using Ubuntu in oracle


When using sdkman on uBuntu 17.04, I do not see an option to install the oracle jdk. How to specify to install oracle jdk using sdkman on uBuntu 17.04?

$sdk list java
 Available Java Version
 > * 8u131-zulu                                                                    

 + - local version
 * - installed
 > - currently in use


You can type sdk ls java and see which versions are available.

At the moment I see 8u141-oracle in the list. So you can install it by sdk i java 8u141-oracle


I have both OpenJDK and Oracle Java installed on my Ubuntu. If the activated java is OpenJDK, is there a way to check the version of Oracle java in bash shell?


update-java-alternatives -l will list all the java versions installed via the alternatives system.

For instance on one of my systems it will display the version and the path:

java-1.6.0-openjdk-amd64 1061 /usr/lib/jvm/java-1.6.0-openjdk-amd64
java-7-oracle 1069 /usr/lib/jvm/java-7-oracle

If you want the oracle one then I guess you could do:

update-java-alternatives -l | grep oracle | awk '{ print $1 }'

This would alternatively find all oracle versions and issue the -version command against each one in the list:

update-java-alternatives -l | grep oracle | awk '{system($3"/bin/java -version")}'

Output may look something like this:

java version "1.7.0_67"
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

One step further would be to parse out the java version from the -version command and simply display it:

(update-java-alternatives -l | grep oracle | awk '{system(""$3"/bin/java -version 2>&1 | grep \"java version\"")}') | awk -F\" '{print $2}'

The 2>&1 is needed because Java will display version to standard error. The output would simply look like this (and could be easily assigned to a bash variable if you needed it that way):


If you had multiple oracle instances this would display the version for each one. If you wanted to find all the versions for every Java you could simply remove the | grep oracle


s@s:~$ sdk ls java
Available Java Versions
 13.ea.18-open       10.0.2-zulu                                            
 12.0.1-sapmchn      10.0.2-open                                            
 12.0.1-zulu         9.0.7-zulu                                             
 12.0.1-open         9.0.4-open                                             
 12.0.1.j9-adpt      8.0.212-zulu                                           
 12.0.1.hs-adpt      8.0.212-amzn                                           
 12.0.1-librca   > * 8.0.212.j9-adpt                                        
 11.0.3-sapmchn      8.0.212.hs-adpt                                        
 11.0.3-zulu         8.0.212-librca                                         
 11.0.3-amzn         8.0.202-zulufx                                         
 11.0.3.j9-adpt      7.0.222-zulu                                           
 11.0.3.hs-adpt      6.0.119-zulu                                           
 11.0.3-librca       1.0.0-rc-16-grl                                        
 11.0.2-open         1.0.0-rc-15-grl                                        
 11.0.2-zulufx       1.0.0-rc-14-grl                                        

Why is it missing ORACLE java 8? I need it to test something, and it's available on my other PC, so I'm wondering what the problem could be.

Ubuntu 19.04.


It is no longer supported. This is the github issue for more information.

As the writer said:

The reason that we're moving to OpenJDK is that Oracle doesn't provide Docker images that are deemed official to Docker, whereas it appears that OpenJDK ones are as shown there. So if we're going to deploy with OpenJDK, then we'd like to match our local dev environment as well.


Oracle hosts a page on how to install Java 1.8 from the binary

I was able to do the following -

Download the x64 tar.gz on the Oracle Downloads page.

Create my directory and move the file there

sudo mkdir /usr/local/java
sudo mv ~/Downloads/jdk-8u45-linux-x64.tar.gz .

And unpack it

sudo tar zxvf jdk-8u45-linux-x64.tar.gz

The binary itself works, because I can call it using the absolute path

> /usr/local/java/jdk1.8.0_45/bin/java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

But I can't call it standalone

> java -version
The program 'java' can be found in the following packages:
 * default-jre
 * gcj-4.6-jre-headless
 * gcj-4.7-jre-headless
 * openjdk-7-jre-headless
 * openjdk-6-jre-headless
Try: sudo apt-get install <selected package>

Even setting $JAVA_HOME as that directory didn't work. Is there a step I'm missing? Does it need to be added to my $PATH?

Edit: I'm aware I could probably install java with sudo apt-get install. I ran into some trouble there in that I wasn't able to apt-get update because of some 404 errors. I'd rather handle that as a separate question/post.



You have just extracted the binary file but you didn't set JAVA_HOME. First set the JAVA_HOME in your profile i.e. in ~/.bashrc file.

export JAVA_HOME=/usr/local/java/jdk1.8.0_45
export PATH=$PATH:$JAVA_HOME/bin

Reload the ~/.bashrc file as

> source ~/.bashrc press enter

Then try again.

> java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)


We have a Vagrant Debian box with the option of installing Java and Solr 6.6. This installation setup was working until last month. Now we can not install Java.

Installation process:


deb trusty main
deb-src trusty main

in our file:

sudo cp /vagrant/provisioning/java-8-debian.list  /etc/apt/sources.list.d/java-8-debian.list;

sudo apt-key adv --keyserver hkp:// --recv-keys EEA14886;

sudo apt-get -qq update
sudo apt-get install -qq -f -y python-software-properties software-properties-common debconf-utils unzip

sudo debconf-set-selections <<< "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true"

Now we have an error:

~$ sudo apt-get install -f -y oracle-java8-installer
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package oracle-java8-installer

How to fix or locate the package?


we also try in terminal without -qq, -f, -y, results are the same.

~$ sudo apt-get  update
Hit jessie InRelease
Hit jessie InRelease                                                                                                                                  
Hit trusty InRelease                                                                                                                                  
Hit jessie InRelease                                                                                                                                 
Hit jessie InRelease                                                                                                                                
Hit jessie/main amd64 Packages                                  
Hit jessie/updates InRelease                                  
Hit jessie/main i386 Packages                                   
Hit jessie/main ppc64el Packages                                                                                
Hit jessie/main amd64 Packages                                                                                                                                      
Ign jessie InRelease                                                                                                                                             
Hit jessie/main i386 Packages                                                                                                 
Hit trusty/main Sources                                                                                 
Hit jessie/main amd64 Packages                                                                    
Hit jessie/main ppc64el Packages                                                                                   
Hit trusty/main amd64 Packages                                                                   
Hit jessie/main Sources                       
Hit jessie/main amd64 Packages
Hit jessie Release.gpg 
Hit jessie/updates/main Sources
Hit jessie/updates/contrib Sources      
Hit jessie/updates/main amd64 Packages                   
Hit jessie/updates/contrib amd64 Packages  
Hit jessie Release
Hit jessie/main Sources
Hit jessie/contrib Sources
Hit jessie/main amd64 Packages
Hit jessie/contrib amd64 Packages
Reading package lists... Done


Sadly you can't install oracje-java8 anymore because Oracle changed their licensing program.

You can use openJDK

apt-get install openjdk-8-jdk

Here you can find additional infos regarding the issue:


when I compile a servlet using java-8-oracle in eclipse and put the classes file in tomcat7/webapps directory , I get a Unsupported major.minor version 52.0 error. But when I compile the version with JDK compliance 1.6 , the servlet runs just fine. Here are my outputs of different settings

$ java -version
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b25)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

the folders in /usr/lib/jvm

$ ls
default-java              java-1.7.0-openjdk-amd64  java-7-openjdk-amd64
java-1.5.0-gcj-4.8-amd64  java-6-openjdk-amd64      java-8-oracle
java-1.6.0-openjdk-amd64  java-6-openjdk-common

Here is my /etc/environment file

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/ga mes:/usr/local/games"

and lastly I appended this line export JRE_HOME="/usr/lib/jvm/java-8-oracle" to my .bashrc in home directory.

So how can I setup tomcat7 to use the java-8-oracle ?


export JAVA_HOME=/usr/lib/jvm/java-8-oracle
export JRE_HOME=/usr/lib/jvm/java-8-oracle/jre

run these in terminal

EDIT 1 ------ run in terminal sudo nano /etc/default/tomcat7 , uncomment line JAVA_HOME and change its value to JAVA_HOME=/usr/lib/jvm/java-8-oracle, and press cntrl+x , Y , ENTER to save the changed settings, now JAVA_HOME is set permanently for tomcat7


I am on ubuntu 14.04 with java 1.6. I want to run the to start the sqldeveloper.

when I run the command ./ the command prompt ask for java home directory full path when I give /usr/lib/jvm/java-6-oracle/jre/bin/java. I get Error: /usr/lib/jvm/java-6-oracle/jre/bin/java/bin/java not found it clearly says that ubuntu unanable to locate the java home directory.

but i have check using command echo $JAVA_HOME and it returns /usr/lib/jvm/java-6-oracle/jre/bin/java/bin/java

to check whether I was correct or not, I followed this

Here is the output of exact location when i trace my java location

varun@mycom:~$ whereis java

java: /usr/bin/java /usr/bin/X11/java /usr/share/java /usr/share/man/man1/java.1.gz

varun@mycom:~$ ls -l /usr/bin/java

lrwxrwxrwx 1 root root 22 Aug  7 11:21 /usr/bin/java -> /etc/alternatives/java

varun@mycom:~$ ls -l /etc/alternatives/java

lrwxrwxrwx 1 root root 39 Aug  7 11:21 /etc/alternatives/java -> /usr/lib/jvm/java-6-oracle/jre/bin/java


Ya your JAVA_HOME should be /usr/lib/jvm/java-6-oracle/ and it should worked


I want to install java8 in Ubuntu image on docker. so I inserted follow codes in dockerfile:

FROM ubuntu:latest
RUN  apt-get update 
CMD ["echo", "apt-get update done ..."]
RUN apt-get -qq install -y wget
CMD ["echo", "wget Done ..."]
RUN apt-get install -y software-properties-common 
CMD ["echo","apt-get install -y software-properties-common"]
RUN add-apt-repository -y ppa:webupd8team/java 
CMD ["echo","add-apt-repository. ..."]
RUN  apt-get update 
RUN  apt-get -qq upgrade
CMD ["echo", "apt-get update done ..."]
# add webupd8 repository
    wget && \
    apt-key add gpg &&\
    apt-get update  &&\
    echo "===> add webupd8 repository..."  && \
    echo "deb trusty main" | tee /etc/apt/sources.list.d/webupd8team-java.list  && \
    echo "deb-src trusty main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list  && \
    apt-key adv --keyserver hkp:// --recv-keys EEA14886  && \
    apt-get update
RUN echo "===> install Java"  && \
  apt-get -qq upgrade && \
  echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections  && \
  echo debconf shared/accepted-oracle-license-v1-1 seen true | debconf-set-selections  && \
   apt-get update &&\
  DEBIAN_FRONTEND=noninteractive  apt-get install -f oracle-java8-installer

but give me this error ```Reading package lists... Building dependency tree... Reading state information... Package oracle-java8-installer is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source

E: Package 'oracle-java8-installer' has no installation candidate ```


there is an image in Docker Hub that Ubuntu+java8. so can use this repository (enter link description here)


I have an ubuntu installation with Oracle JDK 1.8.0_141 was installed using the below guide.

tar was extracted to /opt/jdk and below commands used to set java as default.

update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_05/bin/java 100

update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.8.0_05/bin/javac 100

java -version command works fine after these has been completed.

But when I try to install maven using apt-get it tries to install default-jre rather than using this installed version.

Any idea where can I change this default behavior.



This was solved after setting the kava alternative

sudo update-alternatives --install "/usr/bin/java" "java" "/opt/jdk/jdk1.8.0_144/bin/java" 1

sudo update-alternatives --install "/usr/bin/javac" "javac" "/opt/jdk/jdk1.8.0_144/bin/javac" 1

sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/opt/jdk/jdk1.8.0_144/bin/javaws" 1

It still install the default jdk when installing maven. But uses oracle jdk when building.

Thanks for the wikihow page :


I compile my java code using javac. But I am not sure which compiler it is.

man javac says it is gcj-4.6, which seems provided by GNU. I have OpenJDK Java 7 Runtime installed.

But Wikipedia says javac is from Oracle.

Major Java compilers[edit] As of 2012, the following are major Java compilers:[citation needed]

  • The Java Programming Language Compiler (javac), included in the Java Development Kit from Oracle Corporation, open-sourced since 13 November 2006.

  • GNU Compiler for Java (GCJ), a part of the GNU Compiler Collection, which compiles C, Fortran, Pascal and other programming languages besides Java. It can also generate native code using the back-end of GCC.

  • Eclipse Compiler for Java (ECJ), an open source incremental compiler used by the Eclipse project.

I don't know how to check if I have Oracle's installed.

I am confused. Thanks.


You can pick it yourself! Simply run sudo update-alternatives --config java.


I am learing Java from'HeadFirst Java' My current setup is Ubuntu 14.04

Oracle JDK 1.8 is installed and set as defaut ,Oracle Java is also set as default

I have Many Tools such as AndroidStudio and Eclipse Perfectly working and dont want to break them,by changing to Open JDK

My Problem is

I am tyring an exercise on Java Packaging and Deployement

Directory Structure :MYProject:->Classes,Source

Source:->MyBall.Java Classes:MyPanel.class,MyBall.class etc,manifest.text(contains Min-Class:MyBall)

With Present Working Directory as 'MyProject' I want to make the Source Folder as a JAR

The Book says :

jar -cvmf manifest.txt app1 .jar *.class

should do the trick

But the output i get is

The program 'jar' can be found in the following packages:

 * default-jdk
 * fastjar
 * gcj-4.8-jdk
 * openjdk-7-jdk
 * gcj-4.6-jdk
 * openjdk-6-jdk

Here are the versions:

java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)

javac 1.8.0_11

I find this to be relevant But dont know how to change variable etc , Not a Linux Expert , So Please Guide me!


What you need to do is tell the operating system where the jar program lives. In your home directory, you will most likely have a file called .bashrc. Go to the end of the file and add the following:

export JAVA_HOME=<path to your JDK install e.g. /opt/jdk>
export PATH=$JAVA_HOME/bin:$PATH

This sets your JAVA_HOME environment variable - commonly used by Java-based applications such as Tomcat. It then prepends that directory to your PATH variable. The operating system understands PATH as a list of the parent directories of executable files.

When you have changed your file, type the following at the command prompt to re-load your shell profile:

. .bashrc


Previously, there was an easy way to install Java 8 on Ubuntu using webupd8team repository. But currently it does not work and packages are not located.


So after spending a lot of effort on such a common case I decided to add this post. I used several resources to achieve it.

  1. Uninstall openjdk sudo apt-get purge openjdk*
  2. Go to this blog post and run all steps until 4. If you have issues on step #3 go to step 3 in this post (sorry for numbering :))
sudo mkdir /usr/lib/jvm-oracle

sudo cp ~/Downloads/(name of your tarball) /usr/lib/jvm-oracle 

cd /usr/lib/jvm-oracle

sudo tar -xvzf (name of tarball)

cd jdk1.8.0_(corresponding version)

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm-oracle/jdk1.8.0_{version}/bin/java 1
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm-oracle/jdk1.8.0_{version}/bin/javac 1
sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm-oracle/jdk1.8.0_{version}/bin/javaws 1

sudo cat > /etc/profile.d/
export JAVA_HOME="/usr/lib/jvm-oracle/jdk1.8.0_221"
export PATH="$PATH:${JAVA_HOME}/bin"
  1. (Optional) Make sure java alternatives are updated sudo update-alternatives --config java

You can download Java from here



I found the solution. I ran the following command to find files with the old jdk path:

sudo find / -type f -exec grep -Flm 1 '/usr/lib/jvm/java-8-oracle' {} +

The culprits were in the following directory:



So, I have removed openjdk from my new Ubuntu system and have installed Oracle JDK 8 and Eclipse from their respective websites. I can run a program from Eclipse, however I cannot run it from the command line. I am also not used to using Eclipse (I use NetBeans for my Java class in college.) I noticed that there is no build button in Eclipse. With all of that being said, here is my command line code:

wil@wil-Aspire-E5-521:~/eclipse-workspace/wiltest/src/wiltest$ ls
wil@wil-Aspire-E5-521:~/eclipse-workspace/wiltest/src/wiltest$ java
Error: Could not find or load main class
wil@wil-Aspire-E5-521:~/eclipse-workspace/wiltest/src/wiltest$ java wiltest.testError: Could not find or load main class wiltest.test
wil@wil-Aspire-E5-521:~/eclipse-workspace/wiltest/src/wiltest$ java test
Error: Could not find or load main class test


You need to add the -classpath . command line option.

You can learn more about classpaths here

I believe the command java -classpath . test might work, but it really depends on a number of items that are better explained in the link above.


I recently installed oracle jdeveloper 11g in my home directory on Ubuntu Linux (the installer was a .jar file) and the installer puts the files in ~/Oracle/Middleware/...

since it creates no icons on my desktop my question is that were is the start file to start the jdeveloper program?? (where should I look for the launcher file?)



More details about the installation on Unix here.