1

I have downloaded the java JDK but I am unable to run the program. It is giving me an error like: javac is not recognized as an internal or external command.I have written the program " Hello.java and put it in the C directory.

Where I am doing the mistake? I am compiling it with: javac C:\hello.java

Do I need to give path location of my jdk version>?How do i do that? I have installed my Java in program files of C directory.

C:\>set PATH="%PATH%;C:\Program Files\Java\jdk1.6.0_22\bin"

C:\javac hello.java

I am still getting the error

  • You may need to manually add the path to your java compiler to your environment variables. How you have to do that slightly varies depending on what version of Windows you are using. – Mussnoon Nov 03 '10 at 05:41
  • 1
    See [How can I set the PATH variable for javac so I can manually compile my .java works?](http://stackoverflow.com/questions/2079635/how-can-i-set-the-path-variable-for-javac-so-i-can-manually-compile-my-java-work). – Matthew Flaschen Nov 03 '10 at 05:42
  • I am still getting the same error....plz check the updated part of my question –  Nov 03 '10 at 05:54
  • 1
    @shilps, why are you setting the value of PATH environment variable in double quotes? Your problem starts there. – Vineet Reynolds Nov 03 '10 at 06:04

2 Answers2

1

You will have to first set the bin folder of Java installation in the PATH variable. After that you can try the command javac. You will get a list of help commands. You should be able to compile it.

commands:

javac hello.java

java hello

EDIT - Also, set the CLASSPATH variable.

e.g. set PATH=%PATH%;;

Sid
  • 4,893
  • 14
  • 55
  • 110
1

If you're using windows, you need to set the path variable in the environment variables tab. Setting it inside the command prompt will cause the path setting to be lost after the window is closed.

So:

  1. Go to system / advanced tab / environment variables.
  2. Add javac's path to the PATH variable. Make sure the path is correct.
  3. Close and reopen all command prompts.

Have you tried ending the path with a backslash?

futureelite7
  • 11,462
  • 10
  • 53
  • 87