[英]Script to Change JAVA_HOME System Variable in Windows
I do most of my work against JDK 1.5 - but occasionally I have to change to 1.6. 我做的大部分工作都是针对JDK 1.5的 - 但偶尔我必须改为1.6。 it is a bit painful to have to manually go and change my 'JAVA_HOME' system variable whenever I need to work on a project specific to one or the other (and no, Eclipse doesn't play well in these scenarios - trust me...I've tried.) 每当我需要处理特定于一个或另一个的项目时,必须手动去改变我的'JAVA_HOME'系统变量有点痛苦(不,Eclipse在这些场景中不能很好地发挥作用 - 相信我...... 。我试过了。)
I'm looking for a registry script or windows shell script or for that matter any means by which I can "toggle" this system variable with something that is easy to run. 我正在寻找一个注册表脚本或Windows shell脚本,或者就此而言,我可以用一些易于运行的东西“切换”这个系统变量。
I've messed with the 'set' command, but that only sets the variable for that particular command instance - not globally. 我已经搞乱了'set'命令,但是它只为该特定命令实例设置变量 - 不是全局的。
Thanks in advance. 提前致谢。
EDIT #1: Points of advise: 编辑#1:建议点:
You could use setx
for that purpose 您可以将setx
用于此目的
Like so: 像这样:
setx /M JAVA_HOME "C:\Program Files (x86)\Java\jdk1.6.0_17"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.