1

I tried the following in cl:

javac Main.java

The shell gives an error that "javac" is not a recognized command. I know for a fact I have the Java Platform installed. What could be wrong?

(I use "cd" to set the directory first)

2 Answers 2

3

javac is most likely not on the PATH, and you must give the full path in your command.

Sign up to request clarification or add additional context in comments.

3 Comments

What do you mean? Typing in this? <code>javac C:/Users/......./Main.java</code> That did not work
No, c:/path/to/jdk/bin/javac.exe Main.java. But better is to add c:/path/to/jdk/bin to %PATH% environment variable so that you don't need to enter the full javac path everytime.
If you've got Java environment variables set up, you can also do something along the lines of %JAVA_HOME%\bin\javac.exe Main.java.
0

Add /bin folder to your environment variables.

How do I set or change the PATH system variable?

8 Comments

I followed the instructions for Vista (setting the PATH system variable to the directory of the src) I tried it again and it gave the same error
You need to restart windows after you edit the environment variable.
@Alan Not the location of the src, the location of javac. On windows probably something like C:\Program Files\Java\jdk1.6.0_18\bin
In windows, you need to restart. In linux you dont.
@zengr: this is not true. You just need to close all opened command prompt windows and reopen a new one. @Alan, it's javac.exe. If you don't have such file, you probably haven't installed JDK (for developers), but just JRE (for endusers).
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.