You'll use this tip if you want the NetBeans to produce compiled .class files in a version that is lower than the JDK you're running. That can be useful for instance if the customer you're writing code for is using an older version of Java. You can still use JDK 5 as your development platform, but by setting the source level you specify the Java version for compiler.

How to do it? 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 combobox 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. Here is a screenshot:

If you set for instance the source level to 1.4, the compiler won't accept all the new JDK 5 features like varargs, generics, autoboxing, enhanced for loop, etc. These are all marked as errors. When you compile your project, all classes are created with the source level you specify in here.

Source: Roumen's Weblog

Parent Category: Other API Tips