Right Click on the Project in the Package Explorer.
Build Path -> Configure Build Path -> Libraries.
Now remove JRE System Library 1.7 and add the one for java-8-oracle by clicking on
Add Library -> JRE System Library -> Click Execution Environment and set that to
This resolves the error when building the Java program.