Using both jdk 1.6 and jdk 1.7 for different projects in Eclipse

↘锁芯ラ 提交于 2019-12-04 10:03:05

You can set overall workspace properties to use one version of Java and set individual project properties to use another.

  • To set overall workspace properties, click on Window > Preferences, then navigate to Java > Compiler.
  • To set project properties, right-click on the project and select Properties. Navigate to Java Compiler and check "Enable project specific settings"

You can choose from among the installed JREs for either setting. To tell Eclipse about a newly installed JRE, you can open the workspace preferences and navigate to Java > Installed JREs and then click the "Add" button.

You can change the JDK used by project under Project properties(alt+enter)-> Installed JREs. Also Debug Configuration is your friend. You can set what JDK to use when launching/running an app/program in Eclipse.

This can be done for an Eclipse Run Configuration. You may define multiple such configurations, each of which will reference a "main class" in one of your projects.

  1. In Window -> Preferences -> Java -> Installed JREs define a location for each JRE/JDK.

  2. For a given Eclipse project:

    • right click on the project, select Properties -> Java Compiler, override and set compiliance level settings.

    • Check Use compliance from ..., visit the Java Build Path and be sure you have a JRE Library set that matches the desired compliance level.

  3. For a given Eclipse Run Configuration: Run -> Run Configurations... -> Java Application, select an old or create a new configuration, select the JRE tab and specify the Runtime JRE.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!