Javac Version Not Working

admin 1/6/2022
Active4 months ago

Nov 22, 2012  My javac command is not working. 'javac is not recognized as an internal or external command, operable program or batch file.' -java version WORKS I've tried setting classpath successfully in. Is the -version flag not recognized, or is the 'java' command not recognized? One way to test this is just to type 'java' by itself and run it and see what happens. If the command is not recognized, make sure that the JDK's install path is in your windows PATH. If not, you won't be able to use any of the java executables from the command prompt.

I downloaded this Java JDK and installed it.

But when I go to the command prompt to check the version, it says it's not recognized.

Is anyone else experiencing this issue with the latest Java?

I might not have installed the right version. I need the java that works with grails

when i do a search on my computer for java, it does not find anything

Kuba Ober
74.3k10 gold badges92 silver badges216 bronze badges
4,426244 gold badges558 silver badges905 bronze badges

10 Answers

Windows 2k8 R2 server- For both java [-option] or %JAVA_HOME% to work in the command line you need the following:

In Control Panel->System and Security->System->Advanced system setting->Advanced->Environment Variables->System Variables

Edit the Path variable and add a ';' after the last value and add the the path to the Java bin directory:e.g.- C:Progra~2Javajre6bin

Add the JAVA_HOME Variable with the value set to the path for the java executable:e.g.- C:Progra~2Javajre6binjava.exe


Java is typically installed (on Windows) as C:Program FilesJavajdk<version>

That installation directory has a subdirectory bin which you need to append to your PATH environment variable via the control panel. Then, the commands like java, javac etc. will be available on the command line.

BTW, the same is true for Grails.

Michael BorgwardtMichael Borgwardt
305k67 gold badges442 silver badges674 bronze badges

Press simultaneously the 'windows' and 'pause' buttons on your keyboard, this will bring up the System Preferences dialog.In the Advanced tab, find Environment Variables.

Then, in the User (upper) section, create or update the following two variables :

  • JAVA_HOME = where you put your JDK, eg. C:/Java/SDK
  • PATH = %JAVA_HOME%/bin

Close the dialogs.

Then, in a new command-line console, try 'javac -version' and see if it's detected.It's important that you use a new console, because environment variables are read only when the console is launched.

Olivier CroisierOlivier Croisier

Is the -version flag not recognized, or is the 'java' command not recognized? One way to test this is just to type 'java' by itself and run it and see what happens.

If the command is not recognized, make sure that the JDK's install path is in your windows PATH. If not, you won't be able to use any of the java executables from the command prompt. Here's another link that may help out.

26.4k18 gold badges99 silver badges155 bronze badges

For Linux:

check $PATH and $JAVA_HOME. You can configure it in /etc/environment

From console you can check it like:

For Windows:


My Computer -> Properties -> Advanced -> Environment VariablesCheck there PATH.

From console you can check it like:

Alex IvasyuvAlex Ivasyuv
4,02116 gold badges57 silver badges84 bronze badges

You need to manually add the path to javac.exe and java.exe to your operating system path. The Java installation program doesn't do that for you.

John TopleyJohn Topley
87.7k42 gold badges183 silver badges231 bronze badges

You most likely don't have java.exe in your system's PATH variable.

Mark BMark B
110k17 gold badges190 silver badges195 bronze badges

You installed the JDK. Isn't java.exe part of the JRE? Do you have that installed?


You should have a Java icon in Windows Control Panel. Locate the Java tab and click the View button. That will show you the path to the Java executables.

Last but not least, make sure you have restarted the computer so changes in the PATH variable can take effect.

Álvaro GonzálezÁlvaro González
111k32 gold badges203 silver badges290 bronze badges

For me, it was incorrect line in the PATH

(1) Check PATH: Type 'Edit System Environment Variables' on the search -> System Properties -> Advance -> Environment Variables -> System variables -> Path

(2) On the list, mine was C:Program Files (x86)Common FilesOracleJavajavapath so I just add at the end (the exe files in the javapath folder)

OS: Windows 10 64 bit

Cloud ChoCloud Cho

Not the answer you're looking for? Browse other questions tagged javagrails or ask your own question.

Active1 year, 5 months ago

^I tried the suggestions on this post, and it was SLIGHTLY helpful, but not completely.

I opened up my command prompt and I typed in 'javac' after putting in the path in my Environment Variables and it didn't work, at which point I googled it and found that thread.

I knew that I had closed and re-opened my cmd already, and that didn't work, so I skipped that bit and I saw the part telling me to make sure that javac.exe exists, which I verified with the 'dir' command in the cmd. Afterwords, while in the 'C:Program FilesJavajdk1.7.0_25bin' folder on the command prompt, I typed in the next bit of advice, which was

After entering this into my command prompt, I got the message 'ECHO is on'. Upon seeing this, I typed in 'javac' again and this time, it worked. So I decided to test this out by backing out of the directory and going to a folder in which I had a .java file saved and running it, but it again told me that

This was disappointing. I think it'll only work if I'm INSIDE the bin file on the command prompt, which is annoying because I'm not an administrator on this computer and it will be annoying to always have to get admin permission (from my parents) to code. They will also never give me the password. Can anyone help me? Thanks in advance! And sorry for the huge wall of text...

EDIT: Someone has asked what would the output of 'echo %path%' be. It is this:

^Is it not supposed to say this?

EDIT 2: @brano88...I think I did? I right clicked computer, went to properties, went to advanced system settings, clicked Environment Variables and went to the top part and pressed 'New...' There, I entered the Variable Name as Path and the Variable Value as the location of the bin folder. Is this incorrect? I followed a YouTube tutorial step by step while doing this.

This one:

Java Compiler For Windows 10

Fuzail GilaniFuzail Gilani

5 Answers

How to run .java files from CMD

  1. go to your Computer -> C: -> Program Files -> Java -> jdk1.7.0_25-bin
  2. copy the path (example: C:Program Files (x86)Javajdk1.7.0_25bin)
  3. Go to Control Panel -> System and Security -> System-Advance System Settings -> Advanced -> Environment Variables
  4. open the Environment Variables screen and go to System Variables and look for 'Path'
  5. after finding the Path system variable, double click it or press edit button and in the Variable value you paste the path from java you just copied after the last values already existing there.
  6. Note!
    • make sure you DO NOT enter any extra space in this field as it won't work;
    • make sure you have one semi-colon before pasting the path, example: Path :...%ANT_HOME%bin;C:Program Files (x86)Javajdk1.7.0_25bin
  7. Note! If you previously tried to compile the .java file in a CMD, close that CMD and open it again as the changes made will take effect only using a new instance of CMD
  8. Go to the location of the , example:E:Projects , right-click by holding the Shift button pressed inside your folder and in the options from the window that just appeared select: Open command window here
  9. Another solution is to normally open a CMD and change the directory using :cd command until you reach your folder
  10. After the CMD window opened, type: javac
  11. Note! Make sure the class name written in your is the same as the file name. Example your file name should be: and your class inside that file must also be:

    class HelloWorld { public static void main(String[] args) { System.out.println('Hello World!'); // Display the string. } }

Otherwise, it will not compile!It is successful if no error message is displayed, if the path of the folder appears again in CMD and of course if the HelloWorld.class file appears now in the directory. To check that type the command dir which will show what contains your currect directory.

  1. To finally run the file type in the CMD: java HelloWorld
  2. Observe that no extension is needed when running the file(the file you run already has the .class extension)

This is how it worked for me! If something is not right, please inform me! Thanks!

Ilia Nedoluzhko
9413 gold badges20 silver badges35 bronze badges

For a beginner programmer that doesn't have admin rights on his/her computer, I'd recommend the Eclipse IDE.

Since you already have the JDK the only installation step needed requires no admin rights. From here you must download the 'Eclipse Standard' option, and you will get a very large zip archive. You can extract it onto the desktop or my documents. Windows comes with a utility to do this via drag-and-drop right from the explorer or your machine may have another program such as WinRAR installed to do this.

You can then run eclipse.exe from the place where you extracted it by browsing to, and double-clicking this file.

The IDE is very powerful and self-explanatory. You can create projects, run, and debug code, and it's nice for beginners. It's truly worth the long wait in downloading it.

31.5k4 gold badges66 silver badges91 bronze badges

First, yes you did add JDK to PATH. But you didn't do that correctly. You already have these variables added to PATH: C:Windowssystem32;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0

To add JDK put semicolon before you add it because you have multiple path's assigned to PATH variable. So it should be something like this:

C:Windowssystem32;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:Program FilesJavajdk1.7.0_25bin

Branislav LazicBranislav Lazic
11.1k6 gold badges44 silver badges69 bronze badges

in my case, javac was not working just because while specifying the path to javac in the path variable I gave space after putting semicolon to the end of the previous entry

Siya VarmaSiya Varma

To use javac from command prompt without typing the full location each time you will need to add it to the path.

I am unsure if you can change it without admin privileges, But on windows 7 with admin you can go to start -> Right click My Computer -> Properties -> Advanced system settings -> Advanced -> Enviromental Variables

You can then find the system variable path and append to the end of it, the location of javac.

The exact location of javac will vary depending on what version of the JDK you have installed, During installation you will have been given the option to choose where it was installed.

EDIT: Also make sure you haven't opened cmd as administrator. Or perform the steps in that video on the administrator account.

Adding variables to the top part of the environmental variables menu, mean they only affect the current user. You should be able to do these on normal account if you have someone type in the administrator password.

Owen DelahoyOwen Delahoy

Not the answer you're looking for? Browse other questions tagged javacmdjavac or ask your own question.