我不明白为什么“找不到javac:文件:HelloWorld.java". [英] I could not understand why "javac: file not found: HelloWorld.java"

查看:55
本文介绍了我不明白为什么“找不到javac:文件:HelloWorld.java".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

javac HelloWorld.java

每次在cmd中运行时,以下错误消息都会不断出现

Following error message keeps coming out every time when I run in cmd

javac:找不到文件:HelloWorld.java

javac: file not found: HelloWorld.java

但是,当我添加文件位置

However, when I added my file location

javac D:\User\Documents\Project\HelloWorld.java

它成功运行.为什么?

我尝试将 PATH 的变量值编辑为 D:\ User \ Documents \ Project

I have tried to edit variable value of PATH to D:\User\Documents\Project

但这没用.

推荐答案

您似乎以前从未使用过命令提示符.命令提示符有一个当前目录",就像在文件浏览器窗口中一样,有一个当前目录",即您当前正在查看的目录.

You seem to have never used the command prompt before. The command prompt has a "current directory", just like in a file explorer window, there is a "current directory", the directory that you are viewing right now.

当前目录通常显示在插入符号的左侧.

The current directory is usually shown just to the left of the caret.

上图的当前目录为 C:\ Users \ Mrhope .

键入 dir 以查看当前目录的所有文件和目录.然后,您可以使用 cd 导航到子目录.假设您现在在 Documents 中,就可以这样做

Type dir to see all the files and directories of the current directory. You can then use cd to navigate to a subdirectory. Say you are in Documents now, and you can do this

cd Project

转到 Project 文件夹.顺便说一句, ../表示父目录

to go to the Project folder. By the way ../ means the parent directory

javac HelloWorld.java 中的 HelloWorld.java 是相对于当前目录的路径,因此仅当HelloWorld.java在当前目录中时,此方法才有效.您应该尝试使用 cd 导航到正确的目录,然后使用该命令.

The HelloWorld.java in javac HelloWorld.java is a path relative to the current directory, so this will only work if HelloWorld.java is in the current directory. You should try to use cd to navigate to the correct directory then use that command.

在这里设置 PATH 环境变量是无关紧要的,因为这是在设置JRE的路径.请重新设置.

Setting the PATH environmental variable is quite irrelevant here because that is setting the path of the JRE. Please set it back.

我建议您首先学习 cmd 的基础知识.许多教程都可以在线获得.

I suggest you learn the basics of cmd first. Many tutorials are available online.

这篇关于我不明白为什么“找不到javac:文件:HelloWorld.java".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆