java -cp/javac 在 cmd 提示符下不起作用
我正在尝试通过 cmd 运行 mo 程序:
- 首先我尝试通过“javac Main.java”编译我的 Main.java,之后我在 cmd 中没有消息,
- 第二次我运行“java -cp Main”(Main.class with byte代码),之后我在cmd中没有输出 我尝试重新安装 JDK,但没有帮助。另外,当我在 cmd 中运行“java -version”时,我没有输出。并且没有消息。我已将 JAVA_HOME 路径设置为 JDK 目录,并将其设置为我的 PATH“%JAVA_HOME\bin”。我不能做错什么?请帮助
I am trying to run mo program by cmd :
- first i try to compile my Main.java by "javac Main.java", after that i have no msg in cmd
- second i run "java -cp Main"(Main.class with byte code), after that i have no output in cmd
I tryed reinstall my JDK, but it doesn't help. also when i run "java -version" in cmd i have no output. and no msg.I has set my JAVA_HOME path into JDK dir and set him into my PATH "%JAVA_HOME\bin". what i cant do wrong? Pls help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的 java 路径环境变量设置不正确。您可以尝试运行命令
where java
,它很可能会返回不正确的路径(或什么也不返回)。找到安装 JDK 的正确路径,然后运行此命令将其添加到 cmd 中的路径变量中:
我的系统和路径的示例是:
设置此路径变量后,关闭并重新打开 cmd 窗口,然后尝试运行
java -version。
如果它仍然没有显示任何内容,那么您必须手动更改路径变量并删除旧路径。
Your path environment variable for java is not set correctly. You could try to run the command
where java
and most likely it will return a path that is not correct (or nothing).Find the correct path where your JDK is installed and run this command to add it to the path vars in cmd:
An example for my system and path would be:
After setting this path variable, close and reopen your cmd window and try running
java -version
again.If it still doesn't show anything then you have to manually change your path variables and remove the old path.
确保您已正确设置 java 安装目录的路径。例如我的安装在 D:\Program files\java\jdk-11.0.2
随后我将 JAVA_HOME 设置为
然后打开 path 变量和新条目,如下所示:
然后保存所有更改。关闭所有正在运行的cmd,重新启动,然后重试 java -version
Make sure that you have correctly set the path to the directory in which you have your java installed. For instance mine is settled in D:\Program files\java\jdk-11.0.2
Subsequently I set JAVA_HOME as
Then you open path variable and new entry as following:
Then save all changes. Close all running cmd, start it again and then retry java -version