How to change the JDK version under Eclipse

Eclipse is the most commonly used software development tool for Java developers, and Eclipse relies on JDK. Of course, in order to meet the needs of the project, sometimes we need to change the version of the JDK. Based on my actual experience, this article will introduce to you how to change the JDK version under Eclipse. This article takes the replacement of JDK1.8 to JDK1.6 as an example to illustrate.

method/step

  1. Looking at the project, the original JDK used is 1.8.
    write picture description here

  2. Select the project and click "Build Path" -> "Configure Build Path" to enter the following interface.
    write picture description here

Delete JDK1.8, click "Add Library" -> "JRE System Library", click the "Next" button, select jdk1.6, and click the "Finish" button.

How to change the JDK version under Eclipse
At this point, you can see that jdk has changed from 1.8 to 1.6, click the "OK" button. At this point, the execution program will report the following error.
write picture description here
write picture description here

Select the project, right-click and select "Properties" to enter the project properties interface.
write picture description here

Click "Java Compiler", select "Compiler compliance level", change it to 1.6, and click the "OK" button. At this point, execute the program again, and it can be executed normally.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325471783&siteId=291194637