JDK安装
SET JAVA_HOME=C:\Program Files\Java\jdk<version>
SET CLASSPATH=.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar
SET PATH=%PATH%;%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin
- 验证:
java -version
javac -version
Q1: javac -version报错:
C:\User\UserName>javac -version
'javac' is not recognized as an internal or external command, operable program or batch file.
- 检查环境变量JAVA_HOME、PATH设置是否正确,使用 SET 变量名 输出验证
- PATH为多行,每条单独一行,不能以逗号隔开
常用命令
参考文档
Java8: https://docs.oracle.com/javase/8/docs/technotes/tools/system:unix|windows/command:javac.html
Java5: https://docs.oracle.com/javase/1.5.0/docs/tooldocs/share/.html
javac
编译java源码文件
javac <options> <source files>
javac HelloWorld.java
java
执行编译后的class文件
java [-options] class [args...]
java [-options] -jar jarfile [args...]
java HelloWorld
https://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html (可查看Xss等默认配置)
javadoc
为java文件生成帮助文档
javadoc [options] [packagenames] [sourcefiles] [@files]
javadoc -d <directory> HelloWorld.java
https://docs.oracle.com/javase/8/docs/technotes/tools/unix/javac.html