How to Set Temporary and Permanent Paths in Java?
Last Updated :
12 May, 2025
In Java, the most important task is to set the environment variable on the system. If the Java source file is inside the jdk/bin folder, the path is not required to be set because tools like javac, and java can be accessed globally on the system. If the Java source file is outside the jdk/bin folder, then either a temporary or permanent Java path is required to be set in order to execute the Java source file.
Ways to Set Java Path
There are two ways to set the Java path, that are:
- Temporary Path
- Permanent Path
Now, we are going to discuss how to set the temporary Java path in depth.
Setting Temporary Java Path
To set, the temporary Java path we need to follow the steps which are mentioned below:
- Open command prompt
- Copy the path of jdk/bin directory (e.g. C:\Program Files\Java\jdk-24\bin)
- In the Command Prompt, write the following command
SET PATH=C:\Program Files\Java\jdk-24\bin
Note: This command sets the path for the current prompt session and when the session is closed the path will no longer be valid.

Note: This is used only when we need to use Java for a short time and we do not want to make permanent changes to the system
Now, we are going to discuss how to set the Permanent Java path in depth.
Setting Permanent Java Path
To set the permanent Java path we need to follow the steps which are mentioned below:
Go to Control Panel > System and Security > System.

On the left panel, click on Advanced system settings.

In the System Properties window, click on the Environment Variables button.

Under the System variables, find and select the variable path.
- Select the Path variable and click Edit.
- In the Edit Environment Variable window, click New, and then paste the path of the bin folder.

Click OK to save the changes. Click OK in the Environment Variables window to apply the changes.
Note: To make changes to the Path variable take effect, you might need to restart the Command Prompt or your computer.
This is how we can set both temporary and permanent paths for Java on a Windows system.
Why Set Permanent Java Path?
When we set the path permanently, it makes Java commands like java and javac available every time, when we open a Command Prompt and because of this we do not need to set the path again and again.
How to Verify the Java Path?
After setting the path, we can verify that it sets correctly by checking the version of Java from the command prompt.
Type the following command which is listed below:
java -version
If it sets correctly, we will see the version information in the command prompt. It will confirm that the path is working correctly.
Like this we, can also check the compiler version
javac -version
If we get the Java version on the command prompt, it means the path is set correctly.
Similar Reads
How to set Temporary and Permanent Paths in Java
In Java, the most important task is to set the environment variable on the system. If the Java source file is inside the jdk/bin folder, the path is not required to be set because tools like javac, and java can be accessed globally on the system. If the Java source file is outside the jdk/bin folder
3 min read
How to Set Java Path in Windows and Linux?
PATH is an environment variable that is used by Operating System to locate the exe files (.exe) or java binaries ( java or javac command). The path once it is set, cannot be overridden. The PATH variable prevents us from having to write out the entire path to a program on the Command Line Interface
4 min read
How to Update the Java Version in Windows?
Java is a high-level, robust, object-oriented, and secure programming language that was developed in the year 1995 by Sun Microsystems (which is now part of Oracle group), and James Gosling is known as the father of Java. Â It is a general-purpose programming language intended to let programmers writ
4 min read
How are Java Objects Stored in Memory?
In Java, all objects are dynamically stored in the Heap memory while references to those objects are stored in the stack. Objects are created with the help of "new" keyword and are allocated in the heap memory. However, declaring a variable of a class type does not create an object it only creates r
5 min read
Reading and Writing Properties File in Java
The property file is a file we use in the Java Programming language to keep the configuration parameters. These files we called Resource Bundle because it is a bundle of resources that we are going to use in the application. What are the configuration parameters? Configuration parameters are the par
4 min read
How to Install Java on Windows, Linux and macOS?
Java is a versatile programming language widely used for building applications. To start coding in Java, you first need to install the Java Development Kit (JDK) on your system. This article provides detailed steps for installing Java on Windows 7, 8, 10, 11, Linux Ubuntu, and macOS.Download and Ins
5 min read
Standard Practice For Protecting Sensitive Data in Java Application
We can use encryption techniques to save our data. Encryption is the method by which information is converted into secret code that hides the information's true meaning. The science of encrypting and decrypting information is called cryptography. In computing, unencrypted data is also known as plain
6 min read
Path toUri() method in Java with Examples
The toUri() method of java.nio.file.Path interface used to return a URI to represent this path. This method converts this path into an absolute URI with a scheme equal to the URI scheme that identifies the provider. The exact form of the scheme-specific part is highly provider dependent. In the scen
2 min read
Create a Temporary File in Java
In Java, we can create a temporary file using an existing method known as File.createTempFile() method which creates a new empty file on the specified directory. The createTempFile() function creates a temporary file in a given directory (if the directory is not mentioned then a default directory is
4 min read
Automatic Resource Management in Java ( try with resource statements )
Java provides a feature to make the code more robust and to cut down the lines of code. This feature is known as Automatic Resource Management(ARM) using try-with-resources from Java 7 onwards. The try-with-resources statement is a try statement that declares one or more resources. This statement e
5 min read