Maven: javac: source release 1.6 requires target release 1.6

后端 未结 6 1062
说谎
说谎 2020-12-08 04:48

NOTE: This appears to be a limit in the \"javac\" program.

I have Java 6 code that needs to be built for a Java 5 JVM. My previous work with the javac ant target (

6条回答
  •  独厮守ぢ
    2020-12-08 05:47

    The real question is thus to use @Override in source files that need to be compiled in Java 1.5 class files.

    javac -source 1.5 -target 1.5 aFileWithOverride.java
    

    will do just that. In jdk 7, this will lead to a warning

    [options] bootstrap class path not set in conjunction with -source 1.5
    

    which is absent in jdk 6.

    To get rid of this warning a special boot class jar can be created by adding the java 6 (or higher) java.lang.annotation package to a java 5 rt.jar.

提交回复
热议问题