"Javac" doesn't work correctly on Windows 10
Asked Answered
C

21

26

the problem is that I upgraded to Windows 10 and now I'm installing my tools to programming and now that I installed the JDK 7 of Java, when I try to use in the cmd the command: - "javac"

The result of this is: "javac" is not recognized as an internal or external command...

But I was edited the PATH with the correct link of jdk, because when I use "java", it is ok.

Now, I tried in the console with this command: PATH=%PATH%;"C:\Program Files\Java\jdk1.7.0_79\bin"

And when I executed the command "javac" it works, but now, when I open other console, it doesn't work, or when I restart the console, this command is not recognized.

What could be the problem?

Carraway answered 10/8, 2015 at 17:15 Comment(3)
you must add the bin directory to your PATH. The procedure is the same as under Windows 7.Lyonnesse
Try SET PATH="C:\Program Files\Java\jdk1.7.0_79\bin";%PATH%Discredit
@ThorbjørnRavnAndersen Really, I don't know what was the problem, I was playing with the Variables of Path and then it works. I think that I had to put one ";" at the end in the Path, but I'm not sure. But thanks for you time and your help. GreetingsReagent
N
26

java is part of the JRE, not the JDK.

You need to add the JDK bin to the system PATH, in

"Control Panel" | System | Advanced | "Environment Variables"

Nibble answered 10/8, 2015 at 17:17 Comment(4)
Yeah, I know, but the problem is not the command "java", the problem is when I try to use "javac"Reagent
@Leo: the fact that "java" works only proves that the JRE is in the path. It does not prove that the JDK is in the path. By default, IIRC, the JDK installer doesn't add itself to PATH. You must do so yourself.Thyrsus
@Leo: See my second paragraph.Nibble
Really, I don't know what was the problem, I was playing with the Variables of Path and then it works. I think that I had to put one ";" at the end in the Path, but I'm not sure. But thanks for you time and your help. GreetingsReagent
I
16

Her's how I configure System variable on Windows 10 :

enter image description here

Inquisition answered 1/4, 2016 at 10:50 Comment(0)
T
10

I am totally new to java and spent hours trying to get the problems with PATH and CLASSPATH worked out. There was one person who said to restart the command prompt after you modify the environment variables; that was it for me. While you are testing different configurations, make sure to relaunch the command prompt before testing. It seems like there are at least 2 different ways of setting this up. I went with the following:

1) In System Variables, add

JAVA_HOME = c:\program files (x86)\java\jdk1.8.0_121

2) In System Variables, add the following to existing Path...

%JAVA_HOME%\bin

That's it. No need for quotes around anything. No double forward slashes or anything else. I think it would also work if I removed the java_home variable and just listed the explicit path to bin in the PATH variable, but I'm not touching it again now that it finally works.

Theran answered 22/6, 2017 at 0:16 Comment(1)
For some reason in Windows 10, this won't work. Put the full path in PATH variable instead of using %JAVA_HOME%. Check out this answer: https://mcmap.net/q/119080/-39-java-39-is-not-recognized-as-an-internal-or-external-command-operable-program-or-batch-file-in-windows-10Procephalic
O
9

After adding C:\Program Files\Java\jdk1.8.0_73\bin to the system variables I turned off my command prompt and opened another one. Then it worked.

Oxytocic answered 23/10, 2016 at 17:34 Comment(1)
+1 - Close cmd and re-open it solved my problem :) (Javac is not recognized after setting it up in environment variable)Lawsuit
E
6

Maybe a bit late, but i had same problem.

Click on "Move up" button for Java path and move it at top.

It fixed problem for me

Eckhart answered 6/12, 2015 at 8:43 Comment(2)
It could be other solution but in my case, It needed a ; at the end of the path :)Reagent
This worked for me on a fresh install of Windows 10 on JDK 1.8.0_101. The only other things in my path were npm and Visual Studio Code.Maren
T
3

just add C:\Program Files\Java\jdk1.7.0_80\bin as the path in environmental variables. no need to add java.exe and javac.exe to that path. IT WORKS

Trig answered 16/2, 2016 at 3:31 Comment(0)
C
2

I added below Path in environment variable

;%JAVA_HOME%/bin instead of %JAVA_HOME%\bin

in my case , it fix the problem

Cirenaica answered 16/6, 2016 at 13:8 Comment(0)
R
2

I had the same issue on Windows 10 - the java -version command was working but javac -version was not. There are three things I did:

(1) I downloaded the latest jdk (not the jre) and installed it. Then, I added the jdk/bin path tan o environment variable. In my case, it was C:\Program Files\Java\jdk-10\bin. I did not need to add the ; for Windows 10.

(2) Move this path to the top of all the other paths.

(3) Delete any other Java paths that might exist.

Test the java -version and javac -version commands again. Voila!

Ramayana answered 1/4, 2018 at 19:51 Comment(0)
S
1

For some reason it worked for me to add quotation marks to the path folder on windows 10. not C:\Program Files\Java\jdk 1.8.0_111\bin, but "C:\Program Files\Java\jdk 1.8.0_111\bin".

Socioeconomic answered 21/10, 2016 at 0:6 Comment(0)
S
1

now i got it finally! make sure that there are no spaces before and after the path and put the semi-colon on both sides without spaces

Saline answered 30/11, 2016 at 12:30 Comment(0)
D
0

The PATH is for current user, instead you can add a CLASSPATH and below link would help you more PATH and CLASSPATH

Drosophila answered 10/8, 2015 at 17:21 Comment(2)
I tried the two options: "set PATH=%PATH%;C:\Program Files\Java\JDK1.6.20\bin" And : "export PATH = ${PATH}:/opt/Java/JDK1.6.18/bin" And the effect is the same, when I use that commands, the command "javac" works but now I opened other console, "javac" doesn't work. but in the console where I ejecute the commands (expot PATH... ) works. And I'm confused, because I don't know what could be the problem.Reagent
Really, I don't know what was the problem, I was playing with the Variables of Path and then it works. I think that I had to put one ";" at the end in the Path, but I'm not sure. But thanks for you time and your help. GreetingsReagent
C
0

I added below Path in environment variable

C:\Program Files\Java\jdk1.8.0_91\bin

and then compiled the program but got the error then I restarted the system and again compiled the program

This time it worked :)

Carlyn answered 2/6, 2016 at 22:30 Comment(0)
F
0

Add java path to environment variables and move it to the top of all the paths available there. It worked for me.

Freudian answered 5/3, 2017 at 11:57 Comment(0)
D
0

To be sure about your path, you can use double quotes " to locate the path or if you are in Windows, you can browse to path to select "C:\Program Files\Java\jdk1.8.0_121\bin" folder.

Dialect answered 9/5, 2017 at 15:3 Comment(0)
R
0

in the search window type 'environment variables' this should give you a link to editing the variables. On the variables editing page there is an upper section and a lower section in the lower section add NEW,type path C:\Program Files\Java\jdk-10\bin this worked great for me and it finds the compiler all the time.

Ravelment answered 4/4, 2018 at 17:58 Comment(0)
S
0

Kind of beating a dead horse now but, I want to clarify one thing that may not be quite so obvious. Yes indeed you need to edit the PATH environment variable as already stated many times. The key for me was to edit the PATH under SYSTEM variables. I had inadvertently edited the PATH under USER variables. Why did this matter? On my machine I have to log in as an Administrator to edit environment variables. So editing the User variables was not helping because I run the command prompt under my login (non-admin) account. Grrr!

Also, I found that closing the command prompt window, and re-opening it after the PATH variable update was required. Changing the order of the values, adding semi-colons, etc. didn't make a difference for me.

Cheers

Stomy answered 20/6, 2018 at 1:42 Comment(0)
A
0

what I did is:

I typed ; accidentally in front in the path variable and then hit OK, after this if I again edit it was nowhere going to the same page as earlier, it opened a new page as defined for user variables and then I was able to remove double quotes in front of the PATH VARIABLE. Everything worked fine then. :)

Did it just now.

Amuck answered 21/7, 2018 at 19:41 Comment(0)
S
0

If you have set all PATH variables correctly after installation, just restart it.

I had the same problem, I had also installed new Windows7 OS then I upgraded it to Win 10. Then i started setup necessary tools like IntelliJ, Java jdk,jre, eclipse so on. In cmd, java -version worked but javac compiler got unrecognized. I checked and all good, the files in the folders, path are correct and so on.

I restarted and checked it again in cmd ,it worked.

Shimmery answered 17/2, 2020 at 0:30 Comment(0)
A
-1

Add

PATH = C:\Program Files\Java\jdk1.8.0_66\bin 

in Advanced system setting. Then Choose Environment Variable.

Agripina answered 24/11, 2015 at 10:42 Comment(0)
H
-1

for windows 10 Users Use Java path( JDK Bin location) AS "C:\Program Files\Java\jdk-9.0.1\bin" it will work.

Hydrodynamics answered 17/12, 2017 at 7:47 Comment(0)
C
-1

Points to remember, do as the image shows. Move the highlighted bar up using move up button, this will help.

Censurable answered 23/10, 2018 at 11:27 Comment(1)
This is beside the point. Please have a look at the accepted answer.Clarendon

© 2022 - 2024 — McMap. All rights reserved.