Hello Guys!!! hope you all are doing well!!!
Today a quick and short discussion for installing and using multiple JDK on Ubuntu(Linux) System.
As a Android system developer (generally AOSP framework) we need different Open JDK for different Android platform. As for example, Let say if we want to build Android KK then we have to use JDK 1.5 or 1.6, for Android M we need JDK 1.7, for Android N we need Open JDK 1.8.
first let us install the two different versions of JDKs on our system.
#type the command on the terminal to install JDK 9:
$ sudo apt-get install openjdk-9-jdk
you may ask to enter password.so enter password to finish the installation, after installation gets complete,you can confirm it by typing in the terminal:
$ java -version
it will show the version of JDK which you just installed.
now we have to install other version of JDK. # Install JDK 8 by command in terminal:
$ sudo apt-get install openjdk-8-jdk
now we have both JDK 9 and JDK 8 installed on our system.
if you enter java -version on terminal,it will give only default version of JDK not the both. so to check both installed versions of JDK,enter following command on terminal:
$ update-java-alternatives --list
it will give you both versions of JDK like this:
now if you want to switch from the default version of JDK to your desired version, enter the
following command on terminal:
$ sudo update-alternatives --config java
after entering the command you will get the list indicating the current JDK version by prefixing * on it. Here below in our case it is JDK 9 which is set by default.
Now we can enter the number of the JDK version which you want to switch to or just press enter key if you want to keep the current one.
That's all now you can switch to any installed version of JDK whenever you want.
For installing Java 6 (JDK/JRE 6)
After successfully installing oracle java using above step verify installed version using following command.
java -version or javac -version
Webupd8team is providing a package to set environment variables, Install this package using following command.
Same way you can install Java 7 , just run the following command
sudo apt-get install oracle-java7-installer
Second approach
Download the .deb packages for 64-bit architecture from archive.ubuntu.com and install this JDK package by using Run dpkg for each of the .deb files you downloaded.
$ sudo dpkg -i {downloaded.deb file}
To fix missing dependencies:
$ sudo apt-get -f install
Thanks
Saurabh
Happy Coding!!!
Today a quick and short discussion for installing and using multiple JDK on Ubuntu(Linux) System.
As a Android system developer (generally AOSP framework) we need different Open JDK for different Android platform. As for example, Let say if we want to build Android KK then we have to use JDK 1.5 or 1.6, for Android M we need JDK 1.7, for Android N we need Open JDK 1.8.
first let us install the two different versions of JDKs on our system.
#type the command on the terminal to install JDK 9:
$ sudo apt-get install openjdk-9-jdk
you may ask to enter password.so enter password to finish the installation, after installation gets complete,you can confirm it by typing in the terminal:
$ java -version
it will show the version of JDK which you just installed.
now we have to install other version of JDK. # Install JDK 8 by command in terminal:
$ sudo apt-get install openjdk-8-jdk
now we have both JDK 9 and JDK 8 installed on our system.
if you enter java -version on terminal,it will give only default version of JDK not the both. so to check both installed versions of JDK,enter following command on terminal:
$ update-java-alternatives --list
it will give you both versions of JDK like this:
now if you want to switch from the default version of JDK to your desired version, enter the
following command on terminal:
$ sudo update-alternatives --config java
after entering the command you will get the list indicating the current JDK version by prefixing * on it. Here below in our case it is JDK 9 which is set by default.
Now we can enter the number of the JDK version which you want to switch to or just press enter key if you want to keep the current one.
That's all now you can switch to any installed version of JDK whenever you want.
For installing Java 6 (JDK/JRE 6)
After successfully installing oracle java using above step verify installed version using following command.
java -version or javac -version
Webupd8team is providing a package to set environment variables, Install this package using following command.
Same way you can install Java 7 , just run the following command
sudo apt-get install oracle-java7-installer
Second approach
Download the .deb packages for 64-bit architecture from archive.ubuntu.com and install this JDK package by using Run dpkg for each of the .deb files you downloaded.
$ sudo dpkg -i {downloaded.deb file}
To fix missing dependencies:
$ sudo apt-get -f install
Thanks
Saurabh
Happy Coding!!!
hello,
ReplyDeletei just want to say that you have clearly mention the process very clearly and i also found it is very much easy to understand. keep sharing.
android app development company in chennai
Great post.It seems to be interesting and gave me lot of information,Thank for sharing it.I am looking forward for new articles.keep it up.
ReplyDeleteWebsite Development Company in Bangalore | Website Design Company in Bangalore | Mobile App Development Companies in Bangalore | Game Development Companies in Bangalore