【发布时间】:2013-04-29 22:29:43
【问题描述】:
当我尝试用 javac 编译这个类时,我得到一个编译错误并且没有创建 Test.class。
public class Test {
public static void main(String[] args) {
int x = 1L; // <- this cannot compile
}
}
但是当我在 Eclipse 中创建这个类时,我可以看到 Test.class 出现在 target/classes 中。当我尝试使用 java.exe 从命令行运行此类时,我得到了
线程“main”java.lang.Error 中的异常:未解决的编译问题:
类型不匹配:无法从 long 转换为 int
Eclipse 是否使用其自己的特殊 Java 编译器来创建损坏的 .class? java.exe如何知道.class中的编译问题?
【问题讨论】:
-
+1。好问题,我从来没想过:)
标签: java eclipse compiler-errors