managing multiple versions of JDK: invalid source release error

前端 未结 4 475
抹茶落季
抹茶落季 2021-01-20 02:29

I have jdk 1.6 and 1.7 installed.

I have updated my JAVA_HOME variable to

C:\\Program Files\\Java\\jdk1.6.0_24;C:\\Program Files\\Java\\jdk1.7.0


        
相关标签:
4条回答
  • 2021-01-20 03:05

    Your jdk is still pointing to JDK 1.6. javac is bundled with jdk, while java -version ideally runs even if jre is installed properly.

    0 讨论(0)
  • 2021-01-20 03:09

    The simplest solution would be to use the java_home tool.

    /usr/libexec/java_home -v 1.7.0_51 --exec javac -version
    
    0 讨论(0)
  • 2021-01-20 03:22

    Your "javac -version" test shows that you are using javac 1.6. Then you are trying to build for 1.7 which is a future version that is unknown to the 1.6 compiler. I would do as some comments suggests and only define one JDK for a given project.

    0 讨论(0)
  • 2021-01-20 03:30

    What about javac -source 1.7 -target 1.7 Test.java?

    0 讨论(0)
提交回复
热议问题