【发布时间】:2018-03-03 16:04:38
【问题描述】:
我正在尝试编写我的第一个名为 HelloWorld 的 Java 程序,但遇到以下错误:
javac:找不到文件:HelloWorld.java
用法:javac
我的系统:Windows 10, 64bit
文件路径:C:\ProgramFiles\Java\jdk9.0.4\bin;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\
我担心 Java 出了点问题。当我在 cmd 中输入 java 时,出现以下错误:
C:\Users\Kamil>java 用法:java [options] [args...] (执行一个类)或 java [options] -jar [args...] (执行 jar 文件)或 java [options] -m [/] [args...] java [选项] --module [/] [参数...] (执行模块中的主类)
主类之后的参数, -jar , -m 或 --module / 作为参数传递给主类。
选项包括:
-d32 Deprecated, will be removed in a future release
-d64 Deprecated, will be removed in a future release
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
--class-path <class search path of directories and zip/jar files>
A ; separated list of directories, JAR archives,
and ZIP archives to search for class files.
-p <module path> A ; separated list of directories, each directory
is a directory of modules.
--upgrade-module-path <module path>...
A ; separated list of directories, each directory
is a directory of modules that replace upgradeable
modules in the runtime image
--add-modules <module name>[,<module name>...]
root modules to resolve in addition to the initial module.
<module name> can also be ALL-DEFAULT, ALL-SYSTEM,
ALL-MODULE-PATH.
--list-modules
list observable modules and exit
-d <module name>
--describe-module <module name>
describe a module and exit
--dry-run create VM and load main class but do not execute main method.
The --dry-run option may be useful for validating the
command-line options such as the module system configuration.
--validate-modules validate all modules and exit
The --validate-modules option may be useful for finding
conflicts and other errors with modules on the module path.
-D<name>=<value>
set a system property
-verbose:[class|module|gc|jni]
enable verbose output
-version print product version to the error stream and exit
--version print product version to the output stream and exit
-showversion print product version to the error stream and continue
--show-version
print product version to the output stream and continue
--show-module-resolution
show module resolution output during startup
-? -h -help
print this help message to the error stream
--help print this help message to the output stream
-X print help on extra options to the error stream
有人可以帮助识别它的含义吗?我重装了,还是一样。
【问题讨论】:
-
有人可以检查路径是否正确吗?
-
包括您的项目结构(即 HelloWorld.java 文件在哪里)以及您从哪里运行 javac?
-
C:\Users\Kamil>cd D:\practice C:\Users\Kamil>javac HelloWorld.java javac: file not found: HelloWorld.java Usage: javac
-
C:\Program Files\Java\jdk-9.0.4\bin
-
文件 HelloWorld.java 在 D 中的“practice”文件夹中