How to change JDK version for an Eclipse project
If you are using maven build tool then add the below properties to it and doing a maven update will solve the problem
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
Click on the Window tab in Eclipse, go to Preferences and when that window comes up, go to Java → Installed JREs → Execution Environment and choose JavaSE-1.5. You then have to go to Compiler and set the Compiler compliance level.
Click on the Add Library button. It brings your screen to point to the Java location.
Select "Directory", button right besides JRE home and point to the installed folder location.
Even though you want to just 1.5 compiler project, you can achieve it by changing compiler settings in Eclipse instead of removing 1.6 JRE and add 1.5 JRE.
GOTO -->JAVA--Compiler---> and change compiler level to `1.5` instead of `1.6`
As davidfmatheson suggested,
Just be careful, especially if you're setting this up for a team of people to work on. If anyone uses anything that is new or changed in 1.6, it will compile, but not run in an environment with JRE 1.5.
Right click project -> Properties -> Java Build Path -> select JRE System Library click Edit and select JDK or JRE after then click Java Compiler and select Compiler compliance level to 1.8