什么是java path环境变量

参考:https://docs.oracle.com/javase/tutorial/essential/environment/paths.html

从orcle官网的文档中可以看到java path环境变量:

java path环境变量就是java在执行命令时 寻找javac这个程序的位置(拓展开来其它应用应该也是这样,资源的环境变量就是某个应用对自己所需要用的资源,所在的位置){一个是程序所在的位置,一个是资源所在的位置}。

The PATH environment variable is a series of directories separated by semicolons (;). Microsoft Windows looks for programs in the PATH directories in order, from left to right. You should have only one bin directory for the JDK in the path at a time (those following the first are ignored), so if one is already present, you can update that particular entry.

The following is an example of a PATH environment variable:

C:\Java\jdk1.7.0\bin;C:\Windows\System32\;C:\Windows\;C:\Windows\System32\Wbem

windows的环境变量用 ; 隔开

设置方法:(原文)

Windows XP

  1. Select Start, select Control Panel. double click System, and select the Advanced tab.
  2. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
  3. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK.

Windows Vista:

  1. From the desktop, right click the My Computer icon.
  2. Choose Properties from the context menu.
  3. Click the Advanced tab (Advanced system settings link in Vista).
  4. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
  5. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK.

Windows 7:

  1. From the desktop, right click the Computer icon.
  2. Choose Properties from the context menu.
  3. Click the Advanced system settings link.
  4. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
  5. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK.

Note: You may see a PATH environment variable similar to the following when editing it from the Control Panel:

%JAVA_HOME%\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem

Variables enclosed in percentage signs (%) are existing environment variables. If one of these variables is listed in the Environment Variables window from the Control Panel (such as JAVA_HOME), then you can edit its value. If it does not appear, then it is a special environment variable that the operating system has defined. For example,SystemRoot is the location of the Microsoft Windows system folder. To obtain the value of a environment variable, enter the following at a command prompt. (This example obtains the value of the SystemRoot environment variable):

echo %SystemRoot%

Update the PATH Variable (Solaris and Linux)

You can run the JDK just fine without setting the PATH variable, or you can optionally set it as a convenience. However, you should set the path variable if you want to be able to run the executables (javacjavajavadoc, and so on) from any directory without having to type the full path of the command. If you do not set the PATH variable, you need to specify the full path to the executable every time you run it, such as:

% /usr/local/jdk1.7.0/bin/javac MyClass.java

To find out if the path is properly set, execute:

% java -version

This will print the version of the java tool, if it can find it. If the version is old or you get the error java: Command not found, then the path is not properly set.

To set the path permanently, set the path in your startup file.

For C shell (csh), edit the startup file (~/.cshrc):

set path=(/usr/local/jdk1.7.0/bin $path)

For bash, edit the startup file (~/.bashrc):

PATH=/usr/local/jdk1.7.0/bin:$PATH
export PATH

For ksh, the startup file is named by the environment variable, ENV. To set the path:

PATH=/usr/local/jdk1.7.0/bin:$PATH
export PATH

For sh, edit the profile file (~/.profile):

PATH=/usr/local/jdk1.7.0/bin:$PATH
export PATH

Then load the startup file and verify that the path is set by repeating the java command:

For C shell (csh):

% source ~/.cshrc
% java -version

For kshbash, or sh:

% . /.profile
% java -version
时间: 2024-08-01 20:03:02

什么是java path环境变量的相关文章

JAVA JDK安装及path环境变量配置

JDK安装 JVM  :JAVA虚拟机 JRE :java运行环境=JVM+核心类库 JDK :JAVA开发工具包=JRE+java开发工具 java开发工具:编译工具(javac.exe) . 运行工具(java.exe) .打包工具(jar.exe)等 JDK下载:https://www.oracle.com/technetwork/java/javase/downloads/index.html JDK安装目录: bin: 存放的是java的开发工具. include :存放的调用系统资源

java基础JDK jvm path环境变量

JDk=JRE +java的开发工具(javac.exe java.exe javadoc.exe)JRE =JVM +Java核心类库 2.为什么 要配置 path环境变量 ?如何配置?JAVA_HOME =bin的上一层目录path =%JAVA_HOME%\bin 3.常用的命令行操作都有哪些(至少四个)cd mdrddelcd ..cd/ 4.创建如下类 使得运行的话可以输出创建一个java 文件: ChairMan.javapublic  class   ChairMan{ publi

配置JAVA的环境变量

Java是由Sun公司开发的一种应用于分布式网络环境的程序设计语言,Java语言拥有跨平台的特性,它编译的程序能够运行在多种操作系统平台上,可以实现"一次编写,到处运行"的强大功能. 1.想要成功配置Java的环境变量,那肯定就要安装JDK,才能开始配置的. 2.安装JDK(按提示向导安装). 3.成功安装之后,进行测试是否真的成功安装,点击[开始]----[运行]----输入 CMD,在命令提示符里面输入"Java -version"并按回车键,出现下图,即为安装

Windows 配置JAVA的环境变量

Java是由Sun公司开发的一种应用于分布式网络环境的程序设计语言,Java语言拥有跨平台的特性,它编译的程序能够运行在多种操作系统平台上,可以实现“一次编写,到处运行”的强大功能. 工具/原料 JDK 1.7 安装包 步骤/方法 想要成功配置Java的环境变量,那肯定就要安装JDK,才能开始配置的.   安装JDK 向导进行相关参数设置.如图:   正在安装程序的相关功能,如图:   选择安装的路径,可以自定义,也可以默认路径.如图:   成功安装之后,进行测试是否真的成功安装,点击[开始]-

一些关于path环境变量的问题

(仅个人观点) 刚学习java的时候很疑惑为什么要配置PATH环境变量,理由是什么 --首先要了解console控制台 计算机的每个操作实际上都是控制台一条一条的dos命令完成的 --在搜索中输入CMD即是计算机的控制台 --以我个人为例,打开控制台显示的是. --然而此时输入[cd 路径]并不能打开不在当前文件夹或者盘下的文件,如不能打开D盘下的文件 --配置环境变量Path路径即是: 作用:在任何路径下都可以打开该文件. 比如,a.txt保存在D:下,在控制台中输入[cd a.txt]若无设

PATH环境变量和CLASSPATH环境变量详解

大凡装过JDK的人都知道要安装完成后要设置环境变量,可是为什么要设置环境变量呢?环境变量有什么作用? 1)PATH详解: 计算机安装JDK之后,输入“javac”“java”之类的命令是不能马上被计算机正确执行的,因为计算机不知道到哪里去找这两个命令. 计算机如何查找命令呢?Windows操作系统根据PATH环境变量来查找命令.PATH环境变量的值是一系列路径,Windows操作系统将在这一系列的路径中依次查找命令,如果能找到这个命令,则该命令是可执行的:否则将出现“‘XXX’不是内部命令或外部

java设置环境变量

1.首先下载安装JDK安装包,安装过程中注意安装到其他盘,不要安装到C盘就好. 2.打开我的电脑--属性--高级--环境变量 : 3.新建系统变量JAVA_HOME 和CLASSPATH 变量名:JAVA_HOME 变量值:C:\Program Files\Java\jdk1.7.0 变量名:CLASSPATH 变量值:.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar; 其中变量值为你自己安装jdk的文件目录这里要注意. 4.选择"系统变量&q

JDK的path环境变量配置(两种方式)

1 path环境变量的作用及配置方式1 1.1 path环境变量的作用 1) 在JDK的bin目录下开发程序容易产生的问题 如果文件过多,不方便管理: 删除自己写过的不需要的文件,可能不小心把JDK自带的工具给删除了. 2) 如何解决问题呢 notepad这样的命令为什么在任何路径下都能够执行,原因是配置path环境变量. path配置的是可执行的文件.exe,配置后可以在不同的盘符下访问path路径下的这些可执行文件. 1.2 Path环境变量的配置方式1 右键点击桌面计算机→选择属性→选择高

windows7设置java的环境变量

win7 下配置 java 环境变量 首先,你应该已经安装了 java 的 JDK 了,笔者安装的是:jdk-7u7-windows-x64 接下来主要讲怎么配置 java 的环境变量,也是为了以后哪天自己忘记了做个备份 1.进入“计算机”的“属性”选项,选择“高级系统设置”,如下图所示: 2.点击“高级系统设置”后,会看到如下图所示的对话框,选择“环境变量”: 3.点击“环境变量”之后,会看到如下图所示的对话框: 4.接下来就是具体的配置过程了: ①.选择上图所示的“新建”, “变量名”:Ja