2024-07-27

How to set path in Java

Operating Systems locate executable files (.exe) and Java binaries using the environment variable PATH ( java or javac command).

We must utilize the java and javac commands to run console-based Java programmes in Windows or Linux environments.

The path does not need to be set if you save the Java source file in the JDK/bin directory because all the necessary tools will be present in the current directory.

However, you must set the JDK path if your Java file is located somewhere other than the JDK/bin folder.

There are two ways to set the path in Java:

1)   To set the Temporary Path of JDK in Windows

To set the temporary path of JDK, you need to follow the following steps:

  • Open the command prompt
  • Copy the path of the JDK/bin directory
 Paste  in command prompt: set path= C:\Program Files\Java\jdk1.6.0_23\bin
set java path through command prompt

1)   To set the Permanent Path of JDK in Windows

For setting the permanent path of JDK, you need to follow these steps:

a) Go to My Computer properties  and Click on the advanced tab

Environment Variables-Java

b) Click on environment variables  and click on new tab of user variables

Write the set path in java in the variable name and paste  path of bin folder in the variable value

 C:\Program Files\Java\jdk1.6.0_23\bin

  Click on   OK   button

Copyright © All rights reserved. | MoreNews by AF themes.