If you are running the IDE in a different JDK version than that of version you have written your Java class code, Netbeans provides the facility to build the project in that version. This tip will show you how to do this.
You can specify the target JDK by right-clicking the Libraries node in Projects View and choosing Properties. Then, go to Sources section and the Source Level combo box is what you are looking for. You can choose source level 1.2, 1.3, 1.4 or 1.5 if your platform is JDK 5.