{"id":22614,"date":"2023-10-27T17:29:04","date_gmt":"2023-10-27T17:29:04","guid":{"rendered":"https:\/\/linuxways.net\/?p=22614"},"modified":"2023-10-27T17:29:04","modified_gmt":"2023-10-27T17:29:04","slug":"how-to-check-jdk-version-in-linux","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/linux-commands\/how-to-check-jdk-version-in-linux\/","title":{"rendered":"How to Check JDK Version in Linux?"},"content":{"rendered":"<p><strong>Java JDK <\/strong>or <strong>Java Development Kit <\/strong>consists of a bundle of Java Development tools and libraries useful in creating components and building software applications that solely use Java Programming. Linux Distributions like Ubuntu use the Java Virtual Machine (JVM) for hosting Java Programs and the necessary tools to run and develop these Java Programs are provided by the JDK.<\/p>\n<p>This article explains how you can check the JDK Version in Ubuntu.<\/p>\n<h2><strong>How to Check JDK Version in Linux\/Ubuntu?<\/strong><\/h2>\n<p>Checking the Java JDK Version in Ubuntu is useful for avoiding any compatibility issues when developing applications with Java. It also helps in troubleshooting bugs in your Java Applications. If the Java JDK is not installed on your Ubuntu System, you can install it by following the <a href=\"https:\/\/linuxways.net\/de\/ubuntu\/how-to-install-java-with-apt-on-ubuntu-22-04\/\">How to Install Java on Ubuntu<\/a> Guide. Multiple methods can be used to check the Java JDK Version through Terminal and each method is explained below.<\/p>\n<h3><strong>Open Terminal<\/strong><\/h3>\n<p>As you have to check the Java version through the Ubuntu Terminal, open the Terminal Directly with the shortcut key \u201cctrl+alt+T\u201d:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1514\" height=\"460\" class=\"wp-image-22615\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-1.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-1.png 1514w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-1-300x91.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-1-1024x311.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-1-768x233.png 768w\" sizes=\"auto, (max-width: 1514px) 100vw, 1514px\" \/><\/p>\n<p>Additionally, the Terminal can be opened by navigating through the GUI. Click on the \u201cMenu Icon\u201d at the bottom-left of the screen:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1920\" height=\"1080\" class=\"wp-image-22616\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-2.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-2.png 1920w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-2-300x169.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-2-1024x576.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-2-768x432.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-2-1536x864.png 1536w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/p>\n<p>Once the Application Menu appears, you will see the Terminal Application Icon:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1920\" height=\"1080\" class=\"wp-image-22617\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-3.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-3.png 1920w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-3-300x169.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-3-1024x576.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-3-768x432.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-3-1536x864.png 1536w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/p>\n<p>Click on it to fire up your Ubuntu Terminal:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"728\" height=\"226\" class=\"wp-image-22618\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-4.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-4.png 728w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-4-300x93.png 300w\" sizes=\"auto, (max-width: 728px) 100vw, 728px\" \/><\/p>\n<h2><strong>Method 1: Using the Java Version Command<\/strong><\/h2>\n<p>The Java Version can be directly checked with the \u201c-version\u201d command. The \u201c-version\u201d command allows us to check the currently installed version of any package in our Ubuntu System. In our case, we run the command below to check the Java JDK version installed on our Ubuntu System:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">java<\/span> <span class=\"re5\">-version<\/span><\/div><\/div>\n<p>The currently installed version will be displayed in the Terminal, in our case, the \u201copenjdk version 11\u201d is installed:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"738\" height=\"213\" class=\"wp-image-22619\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-5.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-5.png 738w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-5-300x87.png 300w\" sizes=\"auto, (max-width: 738px) 100vw, 738px\" \/><\/p>\n<h2><strong>Method 2: Using Update-Alternative List to Find Version<\/strong><\/h2>\n<p>The \u201cupdate-alternatives\u201d maintain and display information about the files on your Ubuntu System. It can be used to display information about Java:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">update-alternatives <span class=\"re5\">--list<\/span> <span class=\"kw2\">java<\/span><\/div><\/div>\n<p>This will list the installed Java Packages and you can see that Java JDK Version 11 is installed on our Ubuntu System:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"724\" height=\"100\" class=\"wp-image-22620\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-6.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-6.png 724w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-6-300x41.png 300w\" sizes=\"auto, (max-width: 724px) 100vw, 724px\" \/><\/p>\n<h2><strong>Method 3: Searching in the Installed Package List<\/strong><\/h2>\n<p>The Java JDK version can also be checked by searching for the installed Java packages in the Installed Packages List. Use the \u201clist\u201d command to list all the installed packages on your Ubuntu System:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> apt list <span class=\"re5\">--installed<\/span><\/div><\/div>\n<p>All the packages that are installed will be listed in the Terminal:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"738\" height=\"398\" class=\"wp-image-22621\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-7.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-7.png 738w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-7-300x162.png 300w\" sizes=\"auto, (max-width: 738px) 100vw, 738px\" \/><\/p>\n<p>Scroll down through the list and look for the \u201cOpenJDK\u201d version of Java:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"735\" height=\"423\" class=\"wp-image-22622\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-8.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-8.png 735w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-8-300x173.png 300w\" sizes=\"auto, (max-width: 735px) 100vw, 735px\" \/><\/p>\n<p>The installed JDK Version can be seen in the List, in our case it is JDK Version 11:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"734\" height=\"400\" class=\"wp-image-22623\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-9.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-9.png 734w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-9-300x163.png 300w\" sizes=\"auto, (max-width: 734px) 100vw, 734px\" \/><\/p>\n<p>Instead of Scrolling Down and looking for the Installed Java Packages, filter your search with the \u201cgrep\u201d command. Use the \u201cgrep\u201d command to list only the packages having the \u201copenjdk\u201d string:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> apt list <span class=\"re5\">--installed<\/span> <span class=\"sy0\">|<\/span> <span class=\"kw2\">grep<\/span> <span class=\"re5\">-i<\/span> openjdk<\/div><\/div>\n<p>The Terminal will display only the \u201copenjdk\u201d packages and in our case, you can see that JDK Version 11 is installed: <img loading=\"lazy\" decoding=\"async\" width=\"734\" height=\"232\" class=\"wp-image-22624\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-10.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-10.png 734w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-10-300x95.png 300w\" sizes=\"auto, (max-width: 734px) 100vw, 734px\" \/><\/p>\n<h2><strong>Bonus Method: Upgrading Java to the Latest Version<\/strong><\/h2>\n<p>Upgrading the Java JDK version to the newest version improves the efficiency of the Ubuntu System by improving the bugs, improving compatibility, and the overall stability of the system. Upgrading to the latest version also helps in the overall security of the system by protecting applications from any vulnerabilities. The steps below explain how you can upgrade to the latest Java JDK Version.<\/p>\n<h3><strong>Download Archive File<\/strong><\/h3>\n<p>To install the latest Java JDK Version on your Ubuntu System, download the \u201ctar.gz\u201d Archive File from the official Java Repository with the \u201cwget\u201d command. The latest Java JDK Version is \u201cOpen JDK Version 12\u201d. Download the \u201ctar.gz\u201d file with the following command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">wget<\/span> https:<span class=\"sy0\">\/\/<\/span>download.java.net<span class=\"sy0\">\/<\/span>java<span class=\"sy0\">\/<\/span>GA<span class=\"sy0\">\/<\/span>jdk12.0.2<span class=\"sy0\">\/<\/span>e482c34c86bd4bf8b56c0b35558996b9<span class=\"sy0\">\/<\/span><span class=\"nu0\">10<\/span><span class=\"sy0\">\/<\/span>GPL<span class=\"sy0\">\/<\/span>openjdk-12.0.2_linux-x64_bin.tar.gz<\/div><\/div>\n<p>The downloading process will start and can be seen in the Terminal. Wait for the File to be completely downloaded:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1146\" height=\"343\" class=\"wp-image-22625\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-11.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-11.png 1146w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-11-300x90.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-11-1024x306.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-11-768x230.png 768w\" sizes=\"auto, (max-width: 1146px) 100vw, 1146px\" \/><\/p>\n<p>The cursor moves to the next line once the Archive File is Downloaded: <img loading=\"lazy\" decoding=\"async\" width=\"1146\" height=\"289\" class=\"wp-image-22627\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-12.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-12.png 1146w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-12-300x76.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-12-1024x258.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-12-768x194.png 768w\" sizes=\"auto, (max-width: 1146px) 100vw, 1146px\" \/><\/p>\n<h3><strong>Create a Java Directory<\/strong><\/h3>\n<p>Create a Directory where the Java JDK Packages will be installed. Inside your \u201c\/usr\u201d path, create a Java Directory with the \u201cmkdir\u201d command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">mkdir<\/span> <span class=\"kw2\">java<\/span><\/div><\/div>\n<p>The \u201cls\u201d command lists the files and folders in the directory and the \u201cjava\u201d directory can be seen inside the \u201c\/usr\u201d directory:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1136\" height=\"98\" class=\"wp-image-22628\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-13.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-13.png 1136w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-13-300x26.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-13-1024x88.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-13-768x66.png 768w\" sizes=\"auto, (max-width: 1136px) 100vw, 1136px\" \/><\/p>\n<h3><strong>Move the Java JDK Archive to the Java Directory<\/strong><\/h3>\n<p>Move the Archive File to the newly created java directory with the \u201cmv\u201d command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">mv<\/span> openjdk-12.0.2_linux-x64_bin.tar.gz <span class=\"sy0\">\/<\/span>usr<span class=\"sy0\">\/<\/span><span class=\"kw2\">java<\/span><\/div><\/div>\n<p>The mouse cursor will move to the next line once the file is moved to the \u201cjava\u201d directory:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1141\" height=\"39\" class=\"wp-image-22629\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-14.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-14.png 1141w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-14-300x10.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-14-1024x35.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-14-768x26.png 768w\" sizes=\"auto, (max-width: 1141px) 100vw, 1141px\" \/><\/p>\n<h3><strong>Extract Archive<\/strong><\/h3>\n<p>Navigate to the \u201cusr\/java\u201d directory with the \u201ccd\u201d command. Once you are in the \u201cjava\u201d directory, use the \u201ctar\u201d command to unpack or extract the \u201ctar.gz\u201d file:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">tar<\/span> <span class=\"re5\">-xzvf<\/span> openjdk-12.0.2_linux-x64_bin.tar.gz<\/div><\/div>\n<p>The \u201ctar\u201d command will start extracting the files:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1145\" height=\"286\" class=\"wp-image-22630\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-15.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-15.png 1145w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-15-300x75.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-15-1024x256.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-15-768x192.png 768w\" sizes=\"auto, (max-width: 1145px) 100vw, 1145px\" \/><\/p>\n<h3><strong>Set Environment Variables<\/strong><\/h3>\n<p>Once the files are extracted, set the environment variables to point programs to that version of Java JDK. To set the Environment Variables for the new Java Version, open the \u201cprofile\u201d file from the \u201c\/etc\u201d directory using the \u201cnano\u201d Command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">nano<\/span> <span class=\"sy0\">\/<\/span>etc<span class=\"sy0\">\/<\/span>profile<\/div><\/div>\n<p>The \u201cprofile\u201d file will open with the default Text Editor:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1139\" height=\"480\" class=\"wp-image-22631\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-16.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-16.png 1139w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-16-300x126.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-16-1024x432.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-16-768x324.png 768w\" sizes=\"auto, (max-width: 1139px) 100vw, 1139px\" \/><\/p>\n<p>Once the file is opened, add the code below inside the file:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"re2\">JAVA_HOME<\/span>=<span class=\"sy0\">\/<\/span>usr<span class=\"sy0\">\/<\/span>java<span class=\"sy0\">\/<\/span>jdk-12.0.2<br \/>\n<span class=\"re2\">PATH<\/span>=<span class=\"re1\">$PATH<\/span>:<span class=\"re1\">$HOME<\/span><span class=\"sy0\">\/<\/span>bin:<span class=\"re1\">$JAVA_HOME<\/span><span class=\"sy0\">\/<\/span>bin<br \/>\n<span class=\"kw3\">export<\/span> JAVA_HOME<br \/>\n<span class=\"kw3\">export<\/span> JRE_HOME<br \/>\n<span class=\"kw3\">export<\/span> PATH<\/div><\/div>\n<p>Press the \u201cctrl+o\u201d keys to write the code to the \u201cprofile\u201d file: <img loading=\"lazy\" decoding=\"async\" width=\"1144\" height=\"488\" class=\"wp-image-22632\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-17.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-17.png 1144w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-17-300x128.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-17-1024x437.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-17-768x328.png 768w\" sizes=\"auto, (max-width: 1144px) 100vw, 1144px\" \/><\/p>\n<p>Press the \u201cctrl+x\u201d keys to close the Text Editor and return to the Terminal.<\/p>\n<h3><strong>Configure Java<\/strong><\/h3>\n<p>Ubuntu by Default will use the Java JDK Version 11. Configure Java to use the latest JDK version using the command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> update-alternatives <span class=\"re5\">--install<\/span> <span class=\"st0\">&quot;\/usr\/bin\/java&quot;<\/span> <span class=\"st0\">&quot;java&quot;<\/span> <span class=\"st0\">&quot;\/usr\/java\/jdk-12.0.2\/bin\/java&quot;<\/span> <span class=\"nu0\">1<\/span><\/div><\/div>\n<p>The cursor moves to the next line indicating that the new Java JDK Alternative is installed in the \u201c\/usr\/bin\/java\u201d path whereas the \u201c1\u201d sets the new alternative to run as default:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1142\" height=\"44\" class=\"wp-image-22633\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-18.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-18.png 1142w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-18-300x12.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-18-1024x39.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-18-768x30.png 768w\" sizes=\"auto, (max-width: 1142px) 100vw, 1142px\" \/><\/p>\n<p>Similarly, install the new Java JDK Alternative in the \u201cusr\/bin\/javac\u201d path and set the priority to \u201c1\u201d:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> update-alternatives <span class=\"re5\">--install<\/span> <span class=\"st0\">&quot;\/usr\/bin\/javac&quot;<\/span> <span class=\"st0\">&quot;javac&quot;<\/span> <span class=\"st0\">&quot;\/usr\/java\/jdk-12.0.2\/bin\/javac&quot;<\/span> <span class=\"nu0\">1<\/span><\/div><\/div>\n<p>The cursor moves to the next line indicating the new Java JDK alternative is installed in the \u201c\/usr\/bin\/javac\u201d path and it is set as default with the priority \u201c1\u201d:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1140\" height=\"49\" class=\"wp-image-22634\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-19.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-19.png 1140w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-19-300x13.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-19-1024x44.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-19-768x33.png 768w\" sizes=\"auto, (max-width: 1140px) 100vw, 1140px\" \/><\/p>\n<h3><strong>Verify Installation<\/strong><\/h3>\n<p>Once the new JDK Version is installed and set to default, verify the installation and the configurations with the \u201c-version\u201d command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">java<\/span> <span class=\"re5\">-version<\/span><\/div><\/div>\n<p>If any previous version of Java was installed, use the following command to check the version:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> update-alternatives <span class=\"re5\">--config<\/span> <span class=\"kw2\">java<\/span><\/div><\/div>\n<p>In our case, Java was installed previously, and by running the \u201c&#8211;config java\u201d command we will get the list of installed versions with their path and priority:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1145\" height=\"212\" class=\"wp-image-22635\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-20.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-20.png 1145w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-20-300x56.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-20-1024x190.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-20-768x142.png 768w\" sizes=\"auto, (max-width: 1145px) 100vw, 1145px\" \/><\/p>\n<p>If you want to keep the default selected version, press \u201center\u201d, otherwise type the selection number to use that version as default. In our case, we have selected \u201c1\u201d to be the default version as it is the newest Java JDK Version installed:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1146\" height=\"205\" class=\"wp-image-22636\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-21.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-21.png 1146w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-21-300x54.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-21-1024x183.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-21-768x137.png 768w\" sizes=\"auto, (max-width: 1146px) 100vw, 1146px\" \/><\/p>\n<p>Once the default version of Java JDK is updated, the Terminal will display the path of the Java being used currently. In our case, Java JDK version 12 is currently being used as default:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1147\" height=\"70\" class=\"wp-image-22637\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-22.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-22.png 1147w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-22-300x18.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-22-1024x62.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-22-768x47.png 768w\" sizes=\"auto, (max-width: 1147px) 100vw, 1147px\" \/><\/p>\n<p>Now, running the Java Version command again, the latest version of Java JDK (in our case JDK Version 12) is used:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1141\" height=\"98\" class=\"wp-image-22638\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-23.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-23.png 1141w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-23-300x26.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-23-1024x88.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/10\/word-image-22614-23-768x66.png 768w\" sizes=\"auto, (max-width: 1141px) 100vw, 1141px\" \/><\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>The Java JDK Version in Ubuntu can be checked by either using the \u201c-version\u201d command, the \u201cupdate-alternative\u201d list, or by searching for the OpenJDK Packages in the Package Manager. All the methods to check the JDK Version are explained in depth in this article.<\/p>","protected":false},"excerpt":{"rendered":"<p>The JDK Version in Ubuntu can be checked by either using the \u201c-version\u201d command, the \u201cupdate-alternative\u201d list, or by searching it in the Installed Packages.<\/p>","protected":false},"author":110,"featured_media":22626,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1049],"tags":[],"class_list":["post-22614","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux-commands"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/22614","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/110"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=22614"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/22614\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/22626"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=22614"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=22614"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=22614"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}