Netbeans - Build targetting JDK 6 but run using Java 7 JRE

Solution 1:

Go to the project properties by right clicking on the left hand pane

Build->Compiling

on lower side you will see Additional Compiler options

give the params as -target 6 and this will compile you code according to JDK 6 and when you will run the program it will run it using JRE 7.