How to Install Multiple JDK's in Windows?17 Mar 2025 | 4 min read The Java Development Kit (JDK) is a vital tool for creating Java-based computer programmes. It provides all of the tools and resources required by developers to construct Java programmes and applets. The Java Development Kit (JDK) combines the Java Virtual Machine (JVM) and the Java Runtime Environment (JRE), making it an essential component of Java development. Install the JDKs keep track of where you're placing it on your computer, such as the folder, disc, and directory. The relevance of this need will become clear in subsequent phases. To install JDKs, users should follow specific steps. During installation, it is crucial to remember the destination folder - the drive and directory where the JDK is saved. The information is vital for subsequent stages of the installation, as the requirement associated with this destination folder will become apparent later on. Step-by-Step ImplementationTwo versions of JDK, namely version 20 and 21, have been installed in the directory C:\Program Files\Java. If necessary, you have the option to download JDKs of different versions and save them in separate directories on different drives. ![]() After adding "C:\Program Files\Java\jdk-20" to the path environment variable, open the Command Prompt and enter "java," followed by pressing Enter. You will probably encounter an error because the "java" command, located in the "bin" directory of the downloaded JDK, cannot be located. Check the "bin" directory of your downloaded JDK for an executable with a .exe extension. The problem is that the Command Prompt cannot locate this application. ![]() When you input a command in the command prompt, Windows tries to find the matching executable. If it can't find it, an error occurs. All executable locations in Windows are stored in an environment variable called "path." In our case, we got an error because we didn't tell the system where to find the Java executable in the path environment variable (like C:\Program Files\Java\jdk-20), and this location changes with each JDK version. To check the value of the path environment variable in Windows, click the search icon next to the start symbol, type "Environment," and choose the option that says "Edit The System Environment Variables." ![]() Following the selection of the mentioned option, a GUI application will open. Subsequently, please navigate to the Environment Variables button on the screen of that specific GUI application and click on it. ![]() The window shown in the following image will appear when you click the Environment Variables button. Navigate to the System Variables section, pick the "Path" variable, and click the Edit button. ![]() The image that appears after clicking the Edit button reveals that the path "C:Program FilesJavajdk-20" is not included in the path environment variable. ![]() Next, click the New button in the displayed picture, add "C:\Program Files\Java\jdk-20," and press OK. Continue pressing OK until the GUI application closes automatically. Afterwards, reopen the "Edit The System Environment Variables" option and verify the updated value for the path environment variable. Refer to the picture below for confirmation. ![]() Now, open the command prompt. If it was already open, close it and reopen it. Then, type "java." It would help if you observed an output similar to the picture below. ![]() To utilize multiple JDKs, we've configured the path to the "bin" folder for JDK version 21 in the path environment variable. It allows for the compilation and execution of Java programs with JDK version 21. To switch to JDK version 21, it's necessary to add the path "C:\Program Files\Java\jdk-21\bin" to the path environment variable. Follow the previously outlined steps to make these additions, remembering that the paths mentioned are specific to our example. Verify the changes through the image below. ![]() Now, considering the paths to the executables in the "bin" directories of JDK versions 20 and 21, it's important to remember that when there are multiple paths in the path environment variable, the system prioritizes the first one, and the rest are overlooked. Open the command prompt, and if it's currently open, shut and reopen it. To check the output, type "java -version". In our scenario, it displays "java version 20.0.1" since the path to the "bin" directory of JDK version 20 is first in the list. Check out the image above to confirm this. ![]() When choosing a specific JDK, ensure that the path to the "bin" folder of that particular JDK is positioned at the top of the list among all the paths to the "bin" directories of the respective JDKs. In the environment variable window, where the path values are visible, you'll see buttons on the right side labeled "MOVE UP" and "MOVE DOWN." Use these buttons to organize the bin path values for your JDKs accordingly. For instance, if you intend to use JDK version 21, choose the path "C:\Program Files\Java\jdk-21\bin" and move it to the top. ![]() After choosing "C:Program FilesJavajdk-21bin," click on the "Move up" button to move it to the top of the list. Press OK and continue pressing OK until the GUI application closes automatically. Afterwards, check the updated values for the path environment variable. Confirm the changes through the image below. ![]() Now, open the command prompt. If it was open before, close and reopen it. Then, type the command "java -version" and observe the result. It should display "java version 21.0.1" since the path to the bin folder of JDK-21 is at the top of the list of JDK bin folder paths. You have now successfully setup the machine to build and run Java programmes using JDK-21. ![]() |
? In programming, most of the time we have to deal with a string that is an important part of the programming language. Sometimes, we require to convert the whole paragraph into a sentence case. In such a case, the first letter of the string must be...
2 min read
In Java, a form for entering authentication credentials to access the restricted page is referred to as a Login form. A login form contains only two fields, i.e., username and password. Each user should have a unique username that can be an email, phone number, or...
3 min read
Named for Frank Grey, Grey Code is a binary numeral system in which there is just a single bit difference between two successive values. It is also known as the "Reflected Binary Code" because the (n-1)-bit form of it may be reflected and appended to itself...
4 min read
In this section, we will learn what is a smith number and also create Java programs to check if the given number is smith or not. The smith number program frequently asked in Java coding tests and academics. Smith Number A Smith number is a composite number whose...
4 min read
Tree traversal is commonly used in tree data structures to access all nodes in some particular or, or in any particular sequence. Another rather engaging mode of traversal is reverse level order traversal in Spiral form whereby many nodes are addressed at each level starting from...
6 min read
Java is a popular and powerful programming language known for its platform independence and robustness. Over the years, Java has evolved, introducing various features and APIs to enhance its capabilities. One such evolution is Project Panama, which aims to improve the connection between Java and native...
4 min read
The java.nio.charset.CharsetDecoder class has an inbuilt method called unmappableCharacterAction() that returns the current action of this decoder in an instance of an unmappable-character error. During the decoding process, the CharsetDecoder class in Java uses the unmappableCharacterAction() method to retrieve the current CodingErrorAction related to managing unmappable...
2 min read
It is a problem frequently asked in interviews of top IT companies like Google, Amazon, TCS, Accenture, Flipkart etc. By solving the problem, one wants to check the logical ability, critical thinking, and problem-solving skill of the interviewee. So, in this section, we are going to...
5 min read
Problem Statement The task entails counting all rows in a given matrix that are either arranged ascending or descending. A row is deemed sorted if all of its items follow a pattern that is neither decreasing (ascending) nor growing. For instance, [1,2,3,4] is in ascending order. On the...
4 min read
The Dependency Inversion Principle (DIP) is one of the five SOLID principles of object-oriented programming (OOP). It is a guideline that helps in writing flexible and maintainable code by promoting the decoupling of high-level modules from low-level modules. In the context of Java programming, the Dependency...
5 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India