错误:-“java”未被识别为内部或外部命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12129872/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 07:42:19  来源:igfitidea点击:

ERROR:- 'java' is not recognized as an internal or external command

javaanth2

提问by test test

I have tried to run the Activiti BPM tool under ANT but i am getting the following error :- ERROR:- 'java' is not recognized as an internal or external command; when i tried to start a demo application using CMD command line under windows 7 i got the following error:-

我曾尝试在 ANT 下运行 Activiti BPM 工具,但出现以下错误:- 错误:- 'java' 未被识别为内部或外部命令;当我尝试在 Windows 7 下使用 CMD 命令行启动演示应用程序时,出现以下错误:-

C:\activiti-5.10\activiti-5.10\setup>ant demo.start
    Buildfile: C:\activiti-5.10\activiti-5.10\setup\build.xml

    demo.install:

    internal.cfg.create:
     [copy] Copying 1 file to C:\activiti-5.10\activiti-5.10\setup\build\activit
i-cfg
      [zip] Building zip: C:\activiti-5.10\activiti-5.10\setup\build\activiti-cf
g.jar
     [echo] copying configuration to ../workspace/activiti-engine-examples/src/m
ain/config
    [unzip] Expanding: C:\activiti-5.10\activiti-5.10\setup\build\activiti-cfg.j
ar into C:\activiti-5.10\activiti-5.10\workspace\activiti-engine-examples\src\ma
in\config

internal.classpath.libs:

internal.taskdef.launch:

h2.start:
     [echo] starting H2 database...
   [launch] launching cmd 'C:\activiti-5.10\activiti-5.10\apps\h2\h2.start.bat '
 in dir 'C:\activiti-5.10\activiti-5.10\apps\h2'
   [launch] waiting for launch completion msg 'TCP server running'...
   [launch]   'java' is not recognized as an internal or external command,
   [launch]   operable program or batch file.
   [launch] launched process completed
     [echo] H2 database started

tomcat.start:
   [launch] launching cmd 'C:\activiti-5.10\activiti-5.10\apps\apache-tomcat-6.0
.32\bin\startup.bat ' in dir 'C:\activiti-5.10\activiti-5.10\apps\apache-tomcat-
6.0.32\bin'
   [launch] waiting for launch completion msg 'Using CLASSPATH:'...
   [launch]   Using CATALINA_BASE:   "C:\activiti-5.10\activiti-5.10\apps\apache
-tomcat-6.0.32"
   [launch]   Using CATALINA_HOME:   "C:\activiti-5.10\activiti-5.10\apps\apache
-tomcat-6.0.32"
   [launch]   Using CATALINA_TMPDIR: "C:\activiti-5.10\activiti-5.10\apps\apache
-tomcat-6.0.32\temp"
   [launch]   Using JRE_HOME:        "C:\Program Files\Java\jdk1.7.0_06"
   [launch]   Using CLASSPATH:       "C:\activiti-5.10\activiti-5.10\apps\apache
-tomcat-6.0.32\bin\bootstrap.jar"

explorer.browser.open:

demo.start:

BUILD SUCCESSFUL
Total time: 5 seconds

Does anyone know what is going wrong ? BR

有谁知道出了什么问题?BR

回答by Cratylus

ERROR:- 'java' is not recognized as an internal or external command;

错误:- 'java' 未被识别为内部或外部命令;

This means that java.exeis not part of your PATH.
Add %JAVA_HOME%\binto your PATHwhere JAVA_HOMEis your installation directory for java

这意味着它java.exe不属于您的PATH.
添加%JAVA_HOME%\bin到您的PATH地方JAVA_HOME是java的安装目录

回答by Reimeus

Just add C:\Program Files\Java\jdk1.7.0_06\binto your PATH.

只需添加C:\Program Files\Java\jdk1.7.0_06\bin到您的路径。

The reason is that the batch file C:\activiti-5.10\activiti-5.10\apps\h2\h2.start.bathas a raw javacommand which relies on java.exebeing on the PATH.

原因是批处理文件C:\activiti-5.10\activiti-5.10\apps\h2\h2.start.bat有一个java依赖于java.exePATH的原始命令。

回答by user2910516

I had a similar issue. For some reason the java JDK was installed correctly on C:\Program Files (x86)\Java BUTin the path it was set to C:\Program Files\Java ... once I corrected the path variable it solved this issue.

我有一个类似的问题。出于某种原因,Java JDK 正确安装在 C:\Program Files (x86)\Java在它设置为 C:\Program Files\Java 的路径中......一旦我更正了路径变量,它就解决了这个问题。

Also, watch out if you have Jenkins and Java using the same port number this can cause the appearance that everything is ok by you will need to have them use separate port numbers. To check for this stop Jenkins if it is running as a service and then restart Tomcat

另外,请注意是否让 Jenkins 和 Java 使用相同的端口号,这可能会导致一切正常,因为您需要让它们使用单​​独的端口号。要检查此停止 Jenkins 是否作为服务运行,然后重新启动 Tomcat