Set the JAVA_HOME variable as noted above, but also set the JRE_HOME variable to the Java Runtime Environment folder (example: C:\Program Files (x86)\Java\jdk1.6.0_23\jre )
To set the windows environment variable, right click on My Computer and select "Properties" and choose the "Advanced" tab on older windows versions, or click the "Advanced system settings" link on new versions of windows. Click the "Environment Variables" button and, in the System Variables section, click the "New" button and add the above variable names and enter the appropriate filesystem paths as the values.
After you've installed Netbeans, check the following:
Open C:\Program Files (x86)\NetBeans 6.0.1\etc\netbeans.conf
Change this value to the location of your JDK folder if it isn't set correctly already:
netbeans_jdkhome="C:\Program Files (x86)\Java\jdk1.6.0_23"