java tutorial - How to set path in Java - java programming - learn java - java basics - java for beginners
- The path is required to be set for using tools, for example, javac, java etc.
- If you are saving the java source file inside the jdk/bin directory, path isn’t required to be set since all the tools will be available in the present directory.
- However if you are having java file outer the jdk/bin folder, it is important to set path of JDK.
- There are two approaches to set java path. They are:
- Temporary
- Permanent
How to set Temporary Path of JDK in Windows
- To set the temporary path of JDK,
- Open command prompt
- copy the path of jdk/bin directory
- write in command prompt: set path=copied_path
For Example:
Learn Java - Java tutorial - temporary path java - Java examples - Java programs
How to set Permanent Path of JDK in Windows
- For setting the permanent path of JDK, you need to follow these steps:
- Click MyComputer properties -> advanced tab -> environment variables -> new tab of user variable -> write the path in variable name -> write the path of bin folder in variable value -> ok -> ok -> ok
For Example:
Step 1
- Go to MyComputer properties
Learn Java - Java tutorial - java permanent path setting - Java examples - Java programs
Step 2
- Click on advanced tab
Learn Java - Java tutorial - java permanent path setting - Java examples - Java programs
Step 3
- Click on environment variables
Learn Java - Java tutorial - java permanent path setting - Java examples - Java programs
Step 4
- Click on new tab of user variables
Learn Java - Java tutorial - java permanent path setting - Java examples - Java programs
Step 5
- Write path in variable name
Learn Java - Java tutorial - java permanent path setting - Java examples - Java programs
Step 6
- Copy the path of bin folder
Learn Java - Java tutorial - java permanent path setting - Java examples - Java programs
Step 7
- Paste path of bin folder in variable value
Learn Java - Java tutorial - java permanent path setting - Java examples - Java programs
Step 8
- Click on ok button
Learn Java - Java tutorial - java permanent path setting - Java examples - Java programs
Step 9
- Click on ok button
Learn Java - Java tutorial - java permanent path setting - Java examples - Java programs
- Now your permanent path is set. You can execute any program of java from any drive.
Setting Java Path in Linux OS
- Setting the path in Linux operating system is similar as setting the path in the Windows OS.
- However here we use export tool sooner than set. Let's see how to set path in Linux OS:
- At this time, we have installed the JDK in the home directory below Root (/home).