ant javac compile抛出异常

时间:2013-07-05 06:35:30

标签: ant build

我是编写ant脚本的新手。我在Java 1.4中有代码,当我编译以下ant脚本

<target depends="init" name="javacompile">
    <javac srcdir="${src}" destdir="${dest}" source="1.4" target="1.4"/>
</target>

我得到了 不支持的major.minor版本49.0异常。

java.lang.UnsupportedClassVersionError:com / sun / tools / javac / Main(不支持的major.minor版本49.0)

1 个答案:

答案 0 :(得分:0)

错误是您的Ant脚本需要Java 1.4,但您正在运行JDK 5.0:

这些是主要/次要数字的映射:

http://en.wikipedia.org/wiki/Java_class_file

J2SE 8 = 52 (0x34 hex),,
J2SE 7 = 51 (0x33 hex),
J2SE 6.0 = 50 (0x32 hex),
J2SE 5.0 = 49 (0x31 hex),
JDK 1.4 = 48 (0x30 hex),
JDK 1.3 = 47 (0x2F hex),
JDK 1.2 = 46 (0x2E hex),
JDK 1.1 = 45 (0x2D hex).

建议:

删除source =“1.4”target =“1.4”限定符(如果可能)。