Ubuntu is the efficient operating system created based on the Debian Linux distribution.
The operating system is used on the web server.
Most of the people use it for its speed and reliability.
You can install a lot of supporting software to the operating system to use applications.
Java is one of the necessary and important programming languages which supports so many types of operating systems.
I know you would love to have that Java packages getting installed in your Ubuntu Operating system.
In this Tutorial:
You will learn how to install Java on Ubuntu using commands in the simplest way step by step.
You can install that default Java very easily.
Your first step would be upgrading the packages using the following command.
Now it's done, and Java is installed in your system.
The following installations are not required, however, if you need, you can install them using the commands below.
If Open JDK is already installed, it will return your message like
But, however, you can install the Oracle JDK on Ubuntu.
If you want to install any version of Oracle JDK, use the below commands.
Oracle JDK 9 is available as easily access release. But it may contain bugs. If you want to use JDK 9, then you can go head.
If you have more than one Oracle Java version versions installed on your machine, then you have to choose which version to use.
This can be done by using the following command.
You can do the same with Java compilers. Use the code below
sudo update-alternatives --config javac
The result will show the list of existing compilers as like below.
You can also execute the above command for the following Java components key tool, Javadoc, and jar signer.
You have to find out the path of the java installation.
Execute the following command, and it will show you the path.
Here the installation path of the version would be like
I hope you could learn how to install Java on Ubuntu using APT Get
..and if you have any suggestions, questions or feedback then kindly leave a comment below.
The operating system is used on the web server.
Most of the people use it for its speed and reliability.
You can install a lot of supporting software to the operating system to use applications.
Java is one of the necessary and important programming languages which supports so many types of operating systems.
I know you would love to have that Java packages getting installed in your Ubuntu Operating system.
In this Tutorial:
You will learn how to install Java on Ubuntu using commands in the simplest way step by step.
What is apt-get?
apt-get is the powerful Ubuntu command line program which installs, upgrades the software packages and removes the old one. APT stands for Advanced packaging tool and sometimes it updates the whole OS.Installing Default JDK/JRE on Ubuntu
Ubuntu 12.04 and earlier version uses Open JDK 6 as Default version, and Ubuntu 12.10+ versions have Open JDK 7.You can install that default Java very easily.
Your first step would be upgrading the packages using the following command.
sudo apt-get install
Now you will see the terminal running commands like this below.selvakumar@noisalesteam2:~$ sudo apt-get update
[sudo] password for selvakumar:
Ign http://dl.google.com stable InRelease
Hit http://dl.google.com stable Release.gpg
Hit http://security.ubuntu.com wily-security InRelease
Hit http://dl.google.com stable Release
Hit http://security.ubuntu.com wily- security/main Sources
Hit http://us.archive.ubuntu.com wily InRelease
Hit http://dl.google.com stable/main amd64 Packages
Hit http://security.ubuntu.com wily- security/restricted Sources
Hit http://security.ubuntu.com wily-security/universe Sources
Hit http://us.archive.ubuntu.com wily-updates InRelease
Hit http://security.ubuntu.com wily-security/multiverse Sources
Hit http://us.archive.ubuntu.com wily-backports InRelease
Hit http://security.ubuntu.com wily-security/main amd64 Packages
Hit http://security.ubuntu.com wily-security/restricted amd64 Packages
Hit http://us.archive.ubuntu.com wily/main Sources
..............
Reading Packages list done....
Once it is done, you have to check whether java installed in the system already. Use this commandjava -version
If Java is installed in the system, the command will return the java version. If not it will show some messages like this.selvakumar@noisalesteam2:~$ java -version
The program 'java' can be found in the following packages:
* default-jre
* gcj-4.9-jre-headless
* gcj-5-jre-headless
* openjdk-7-jre-headless
* gcj-4.8-jre-headless
* openjdk-6-jre-headless
* openjdk-8-jre-headless
Try: sudo apt-get install <selected package>
selvakumar@noisalesteam2:~
So, the java is not installed in your system. To install java use the following command.sudo apt-get install default-jre
Now you will see the command execution lines like thisselvakumar@noisalesteam2:~$ sudo apt-get install default-jre
[sudo] password for selvakumar:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libntdb1 python-ntdb
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
ca-certificates-java default-jre-headless fonts- dejavu-extra java-common
libatk-wrapper-java libatk-wrapper-java-jni libgnomevfs2-0
libgnomevfs2-common libsctp1 lksctp-tools openjdk-7-jre
openjdk-7-jre-headless tzdata tzdata-java
Suggested packages:
equivs libgnomevfs2-bin libgnomevfs2-extra gamin fam gnome-mime-data
icedtea-7-plugin icedtea-7-jre-jamvm sun-java6- fonts fonts-ipafont-gothic
fonts-ipafont-mincho ttf-wqy-microhei ttf-wqy- zenhei fonts-indic
Recommended packages:
libgnome-2-0
The following NEW packages will be installed:
ca-certificates-java default-jre default-jre- headless fonts-dejavu-extra
java-common libatk-wrapper-java libatk-wrapper- java-jni libgnomevfs2-0
libgnomevfs2-common libsctp1 lksctp-tools openjdk-7-jre
openjdk-7-jre-headless tzdata-java
The following packages will be upgraded:
tzdata
1 upgraded, 14 newly installed, 0 to remove and 71 not upgraded.
Need to get 42.0 MB of archives.
After this operation, 66.0 MB of additional d disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://us.archive.ubuntu.com/ubuntu/ wily/main libsctp1 amd64 1.0.16+dfsg-2 [8,414 B]
Get:2 http://us.archive.ubuntu.com/ubuntu/ wily/main java-common all 0.52 [131 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu/ wily/main default-jre-headless amd64 2:1.7-52 [4,086 B]
The line was long. I have cut down a part of it.Now it's done, and Java is installed in your system.
The following installations are not required, however, if you need, you can install them using the commands below.
Installing Open JDK
Use the command below to install open JDK on Ubuntu.sudo apt-get install openjdk-7-jre
The command will install Java Run Time Environment on the system.If Open JDK is already installed, it will return your message like
selvakumar@noisalesteam2:~$ sudo apt-get install openjdk-7-jre
[sudo] password for selvakumar:
Reading package lists... Done
Building dependency tree
Reading state information... Done
openjdk-7-jre is already the newest version.
openjdk-7-jre set to manually installed.
The following packages were automatically installed and are no longer required:
libntdb1 python-ntdb
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 71 not upgraded.
If you need JDK to be installed on your machine, use the below command.sudo apt-get install openjdk-7-jdk
It downloads the package and installs the packages.Installing Oracle JDK
After Oracle had bought Java, they released the Oracle JDK. It is official, but Oracle did not provide that JDK as Default installation for Ubuntu.But, however, you can install the Oracle JDK on Ubuntu.
If you want to install any version of Oracle JDK, use the below commands.
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
You can install any version of Oracle JDK based on your requirement.Install Oracle JDK 7
The version is in use, and you can download and install it using the below command.sudo apt-get install oracle-java7-installer
Install Oracle JDK 8
It is the stable version as of now. You can install Oracle JDK 8 on Ubuntu by using the below command.sudo apt-get install oracle-java8-installer
Agree with their license agreement; then the installation process will start once the packages download.Oracle JDK 9 is available as easily access release. But it may contain bugs. If you want to use JDK 9, then you can go head.
How to Manage Java.
I have mentioned previously how to install various versions of Java.If you have more than one Oracle Java version versions installed on your machine, then you have to choose which version to use.
This can be done by using the following command.
sudo update-alternatives --config java
The command will return all the Java installation you have made. It would look like below.selvakumar@noisalesteam2:~$ sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-8-oracle/jre/bin/java 1081 auto mode
1 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 manual mode
* 2 /usr/lib/jvm/java-8- oracle/jre/bin/java 1081 manual mode
Press <enter> to keep the current choice[*], or type selection number:
Press the number shown in the list to select your desired version of Java.You can do the same with Java compilers. Use the code below
sudo update-alternatives --config javac
The result will show the list of existing compilers as like below.
selvakumar@noisalesteam2:~$ sudo update- alternatives --config javac
There are 2 choices for the alternative javac (providing /usr/bin/javac).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-8- oracle/bin/javac 1081 auto mode
1 /usr/lib/jvm/java-7-openjdk- amd64/bin/javac 1071 manual mode
* 2 /usr/lib/jvm/java-8-oracle/bin/javac 1081 manual mode
Press <enter> to keep the current choice[*], or type selection number:
It can be used the same way you selected the Java version.You can also execute the above command for the following Java components key tool, Javadoc, and jar signer.
Setting Java Home Environment Variable.
To do this:You have to find out the path of the java installation.
Execute the following command, and it will show you the path.
sudo update-alternatives --config java
The command will return the followingHere the installation path of the version would be like
/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
/usr/lib/jvm/java-8-oracle/jre/bin/java
Run this code to edit the pathsudo nano /etc/environment
The file will open and replace the path with your selected path. You have to copy and paste the path here.JAVA_HOME="Your selected path."
Save the file and then reload it.sudo nano /etc/environment
Now check the path using the below command.echo $JAVA_HOME
If it returns the home set path, it means that you set the path
correctly. If not, check you have done the above-said steps correctly.Conclusion
If you found this tutorial useful then kindly share the guide on your preferred social media network.I hope you could learn how to install Java on Ubuntu using APT Get
..and if you have any suggestions, questions or feedback then kindly leave a comment below.
Tidak ada komentar:
Posting Komentar