JDK
标准工具中包含javac
编译器,而Eclipse
开发工具JDT
(Eclipse Java development tools)中默认使用的是其自身实现的兼容编译器ECJ
(Eclipse Compiler for Java)。而且由于JDT
基于ECJ
,所以在Eclipse
中并不能方便地切换编译器。
编译命令
1 |
javac [ options ] [ sourcefiles ] [ classes ] [ @argfiles ] |
编译选项
调试选项
-g
生成所有调试信息,包括局部变量。默认情况下,只生成行号和源文件信息。-g:none
不生成任何调试信息。-g:[keyword list]
仅生成某些类型的调试信息,由逗号分隔的关键字列表指定。有效关键字是:
source
Source file debugging information.
lines
Line number debugging information.
vars
Local variable debugging information.
调试选项(Eclipse工程)
Project->Properties->Java Compiler
在”Classfile Generation”中
Add variable …
Add line number …
Add source file name …
参考链接
“Eclipse Java-development-tools” JDT
“Stackoverflow” javacVSecj
“Oracle Docs” javac