views:

105

answers:

1

I have added Path variable 'C:\Program Files\Java\jdk1.6.0_21\bin' in Environment Variables, but it still gives me this error: 'javac' is not recognized as an internal or external command, operable program or batch file when I try to run javac mycode.java. I am going insane, please help. Thanks.

+4  A: 

Close the command prompt window and open it again so that the new environment variables take effect.

Leniel Macaferi
Of course this step was mentioned in the instructions I linked to the original question. Wonder if he ever read them...
Carlos
Now I tried to change .java file's directory and it works. But it gives me an error: `C:\Users\Tomas>javac hello.javahello.java:1: class my_first is public, should be declared in a file named my_first.javapublic class my_first`
hey
Rename your .java file to my_first.java and try compiling again. The source code file must have the same name of your class, in this case, my_first.
Leniel Macaferi
The error message tells you exactly what is wrong. The name of the file must match the name of the class. Rename hello.java to my_first.java and it should work.
Carlos
It fuc*king works now! Yahoooo!
hey