Proper way to set JAVA_HOME variable to run PhoneGap Apps

Have you ever encounter the following error problem running your apps in phonegap:

Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK

You need to know the path of your Java JDK ex. C:\Program Files\Java\jdk1.7.0_51 Once you have the JDK installation path:

  1. Right-click the My Computer.
  2. select Properties.
  3. Click the Advanced tab
  4. Go to Environment Variables button. Under System Variables, click New.
  5. Enter the variable name as JAVA_HOME.
  6. Enter the variable value as the installation path for the Java Development Kit.
  7. Click OK.
  8. Click Apply Changes.

If still not working, you might need to restart your computer.