Reputation: 61
In Eclipse, I want to use Java 8 for Java applications and continue to use Java 7 for Android apps. I don't want to use retrolambda, at least not now. How can I set this up to work as seamlessly as possible?
Upvotes: 2
Views: 159
Reputation: 100209
Install both JDK7 and JDK8 on your computer. Register both in Preferences -> Java -> Installed JREs
(use Add...
button):
Next, map execution environments JavaSE-1.7 and JavaSE-1.8 to the corresponding JRE installations (make sure that checkbox on the right side points to proper JRE):
In the individual projects properties under Java Compiler always set "Use compliance from execution environment" option:
Finally in the Java Build Path option link the proper execution environment: Java Build Path -> Libraries -> Add Library -> JRE System Library -> Execution environment
and select either JavaSE-1.7 or JavaSE-1.8 (avoid using "Alternate JRE" or "Workspace default" options):
If incorrect JRE System Library was set in your project by default, you should remove it first.
After this setup your project compiler and project build path will be always consistent and your project will be independent on specific computer you're working on. You may open it on properly configured Eclipse (see the IDE setup section) on another computer and will correctly use the selected Java version.
Upvotes: 1