简体   繁体   English

如何在命令提示符下更改类路径?

[英]How to change the classpath in command prompt?

I have created a classpath in command prompt. 我已经在命令提示符下创建了一个类路径。 Later I want to change that classpath to another location. 稍后,我想将该类路径更改为另一个位置。 Please help me. 请帮我。 Thanks 谢谢

I have entered the command "set classpath= d:/java" Now i want to change this class path to some another location. 我输入了命令“ set classpath = d:/ java”,现在我想将此类路径更改为其他位置。

Thanks 谢谢

As per my understanding you want to change the classpath which you have set by command 根据我的理解,您想更改通过命令设置的类路径
set classpath=d:java

can be done in two ways either you can set classpth directly as environment varible by 可以通过两种方式来完成,或者您可以通过以下方式直接将classpth设置为环境变量:
--> Right click on my computer select advanced options ->右键单击我的计算机,选择高级选项
--> there you will see option as environment variables open that option ->在这里,您将看到选项,因为环境变量打开了该选项
--> now you will see multiple variables being set...search for classpath variable if it exist their edit this variable value by just putting semicolon and write ur full classpath ended by semicolon and save it. ->现在,您将看到设置了多个变量...如果存在classpath变量,请搜索它们,只需将分号放进去并写入以分号结尾的完整类路径并保存,即可编辑此变量值。
FOR EG:- 对于EG:

variable name:- CLASSAPTH
variable value- .;C:\Oracle\product\10.1.0\Client_2\jdbc\lib\ojdbc14.jar;

Second option is just set your class in command promt as u have set earlier 第二种选择是按照您之前的设置在命令promt中设置您的类

by opening command prompt 通过打开命令提示符

set classpath=C:\Oracle\product\10.1.0\Client_2\jdbc\lib\ojdbc14.jar;

both the method are easy but i would prefer you should go with first one as by doing that you didn't need to set your classpath again and again after you reboot your system or application. 两种方法都很简单,但我希望您首先使用第一种方法,因为这样做无需在重新启动系统或应用程序后一次又一次地设置类路径。

From the desktop, right click the Computer icon. 在桌面上,右键单击“计算机”图标。 Choose Properties from the context menu. 从上下文菜单中选择“属性”。 Click the Advanced system settings link. 单击高级系统设置链接。 Click Environment Variables. 单击环境变量。 In the section System Variables, find the PATH environment variable and select it. 在“系统变量”部分中,找到PATH环境变量并选择它。 Click Edit. 单击编辑。 If the PATH environment variable does not exist, click New. 如果PATH环境变量不存在,请单击“新建”。 In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. 在“编辑系统变量(或新系统变量)”窗口中,指定PATH环境变量的值。 Click OK. 单击确定。 Close all remaining windows by clicking OK. 单击确定关闭所有剩余的窗口。

For eg: PATH=/usr/local/jdk1.7.0/bin: 例如:PATH = / usr / local / jdk1.7.0 / bin:

If u want to do while running your java program ,you can use 如果您想在运行Java程序时执行此操作,则可以使用

java -classpath C:\java\MyClasses utility.myapp.Cool

for more details about class path see oracle documentation about classpath . 有关类路径的更多详细信息,请参见有关classpath的oracle文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM