简体   繁体   English

创建批处理文件以在Java中设置路径

[英]Creating a Batch File to Set Path in Java

I have installed JDK 1.7.0_17 on my windows7 32 bit machine and created a batch file set java path but it doesn't work. 我已经在Windows7 32位计算机上安装了JDK 1.7.0_17,并创建了一个批处理文件集java路径,但是它不起作用。

I have installed jdk under c:\\program files.... and need to run java from E: and created batch file under E:\\ as follows: 我已经在c:\\ program files ....下安装了jdk,并且需要从E:运行Java,并在E:\\下创建了批处理文件,如下所示:

set path="C:\Program Files\Java\jdk1.7.0_17\bin";

I got the following exception whenever I run the .bat file. 每当我运行.bat文件时,都会收到以下异常。

PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32
\WindowsPowerShell\v1.0\

What is the mistake in my code? 我的代码有什么错误?

尝试这个:

  path="C:\Program Files\Java\jdk1.7.0_17\bin";%path%

After this set path="C:\\Program Files\\Java\\jdk1.7.0_17\\bin"; 在此之后, set path="C:\\Program Files\\Java\\jdk1.7.0_17\\bin"; add pause(); 添加pause();

You mention some exception but I do not see any exception in your question. 您提到了一些例外,但我在您的问题中看不到任何例外。

When you execute the batch file then the PATH variable is set/changed only for that command session. 当执行批处理文件时,仅针对该命令会话设置/更改PATH变量。

If you start new command session then you will not see the changed value. 如果启动新的命令会话,则将看不到更改后的值。

What it is that you want to achieve by just setting the PATH? 您只想通过设置PATH就可以实现什么?

What ever you want to run using java so all that in one batch file/session or set the PATH environment variable manually before running the java command 您想使用Java运行的所有内容,以便在一个批处理文件/会话中全部运行,或者在运行Java命令之前手动设置PATH环境变量

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

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