Wednesday, January 5, 2011

The system cannot find the file specified

Error: Cannot run program "javac": CreateProcess error=2, The system cannot find the file specified
Error while building project

Most probably, such kind of error occurs only ones for the first time whenevr you do the new installations of JDK, JDE etc. This errors comes when your JDE installation cannot locate the JDK installation, particularly \bin folder of JDK installation.

To sort out this error, just set the classpath so that other softwares can locate your JDK installation. On my machine, set the classpath as C:\Program Files\Java\jdk1.6.0_23\bin; Please note that you will need to provide the complete path to the \bin folder of your JDK installation. And then restart your machine. I hope this will sort out this error. That’s it.

How can I set a classpath variable?

Setting a classpath variable is very simple, just follow the steps below:

  1. Right-Click on My Computer
  2. Go to Properties
  3. It will open a window named as System Properties
  4. Click on Advanced tab
  5. Click on a button Environment Variables which you will find at the bottom of the window.
  6. It will open an another window named as Environment Variables with two sections, one is User variables for Administrator, and another one is System variables.
  7. In the System Variables section, scroll to find the variable Path and select it.
  8. Now click the Edit button.
  9. It will open an another small window named as Edit System Variables, with Path as a Variable name and a long string consisting of various path as Variable value. NOTE: Please don’t delete the existing paths.
  10. Then add the complete path e.g. C:\Program Files\Java\jdk1.6.0_23\bin; at the end of the existing path in the Variable value field.
  11. Press OK on each window.
  12. Restart your machine. That’s it!