I would like to start by this post a series of tips for NetBeans 4.1. My goal is to provide a quick solution for questions of the following kind: "I want the IDE to do something but how the heck do I tell it?". I apologize upfront to people who will read the tips and will think that they are just obvious. Hey, NetBeans user base has trippled during past year, so there's a lot of newbies for who it may not be so clear. I'd also like to give more information than you can find in docs, help or FAQ - to give you some background how things work together (or don't). Enough of introduction, here's the first tip.
Setting target JDK
You'll use this tip if you want the IDE 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.Side note: You have probably mentioned that JDK 1.5 is now called JDK 5. There won't be any 1.6 but we'll have JDK 6. If you want to understand why, take a look at this page. The world would be boring, if things would be simple and predictable all the time, wouldn't it? That's one of the advantages of IT industry, there's always something new ;-)