• 淘宝、京东、拼多多购物助手上线,希望大家多多支持!

  • 增加付费可看,结合购物助手

  • 马上要过年了

  • 下载资源可以使用了! :mrgreen:

  • 今天天气一般般!

How to set path in Java

JAVA 空手师 4年前 (2019-11-15) 483次浏览 已收录 0个评论

How to set path in Java

  1. How to set the path of JDK in Windows OS

    1. Setting Temporary Path of JDK
    2. Setting Permanent Path of JDK
  2. How to set the path of JDK in Linux OS

The path is required to be set for using tools such as javac, java, etc.

If you are saving the Java source file inside the JDK/bin directory, the path is not required to be set because all the tools will be available in the current directory.

However, if you have your Java file outside the JDK/bin folder, it is necessary to set the path of JDK.

There are two ways to set the path in Java:

  1. Temporary
  2. Permanent

1) How 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
  • Write in command prompt: set path=copied_path

For Example:

set path=C:Program FilesJavajdk1.6.0_23bin

Let’s see it in the figure given below:


How to set the path in Java


2) How to set Permanent Path of JDK in Windows

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

  • Go to MyComputer properties -> advanced tab -> environment variables -> new tab of user variable -> write path in variable name -> write path of bin folder in variable value -> ok -> ok -> ok

For Example:

1) Go to MyComputer properties
how to set path in java
2) Click on the advanced tab
how to set path in java
3) Click on environment variables
how to set path in java
4) Click on the new tab of user variables
how to set path in java
5) Write the path in the variable name
how to set path in java
6) Copy the path of bin folder
how to set path in java
7) Paste path of bin folder in the variable value
how to set path in java
8) Click on ok button
how to set path in java
9) Click on ok button
how to set path in java

Now your permanent path is set. You can now execute any program of java from any drive.


Setting Java Path in Linux OS

Setting path in Linux OS is the same as setting the path in the Windows OS. But, here we use the export tool rather than set. Let’s see how to set path in Linux OS:

export PATH=$PATH:/home/jdk1.6.01/bin/

Here, we have installed the JDK in the home directory under Root (/home).

You may also like:

How to set classpath in Java


空手之道 , 版权所有丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:How to set path in Java丨部分内容为转载,如有侵权,请联系,删除处理!丨
喜欢 (0)

您必须 登录 才能发表评论!