• Post Reply Bookmark Topic Watch Topic
  • New Topic

javac is still not recognized; Tried everything  RSS feed

 
Nick Woods
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm a complete beginner in Java, and everything related to IT, but i decided to learn Java with Headfirst Java.
I have a Windows 10, download Java jdk1.8.0_60 and the API documentation. When i type in the command prompt: javac HelloWorld.java, the answer is: javac is not recognized as an internal or external command, operable program or batch file. I've set the path in the environmental variables like this:C:\Program Files\Java\jdk1.8.0_60\%JAVA_HOME%\bin\javac.exe. Didn't help. How do I solve this problem?
 
Knute Snortum
Sheriff
Posts: 4281
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

All you need in the PATH variable is C:\Program Files\Java\jdk1.8.0_60\bin. This tells Windows where to find javac.
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Also, it may be a good idea to *not* delete your previous PATH -- meaning that the java bin directory should be added to the path, and not replace the path.

Henry
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum wrote:All you need in the PATH variable is C:\Program Files\Java\jdk1.8.0_60\bin. This tells Windows where to find javac.

all you need to ADD to the path is this...by all means do NOT REPLACE everything there with just this.
 
Paweł Baczyński
Bartender
Posts: 2086
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And after you change the variable you need to reopen or reload the console (by typing cmd).
 
Karan Pant
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Close cmd, and launch it again.

Make sure you have set the environment variables correctly

Add a user variable 'with
Variable Name:- JAVA_HOME
Variable Value :- C:\Program Files\Java\jdk1.8.0_20

and go to path system variable and add this line to the front(%JAVA_HOME%\bin;)
 
Knute Snortum
Sheriff
Posts: 4281
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry guys; my post was poorly worded. To be specific, if your PATH variable looks like this:

C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem

...then add the Java bin to the end, like this:

C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Java\jdk1.8.0_60\bin

Notice the semicolon (;) between the old end of the PATH and the new entry.
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum wrote: . . .
...then add the Java bin to the end, like this:
. . .
Actually it is often better to add the Java path to the beginning of the PATH. If the rest of the PATH contains a java tool which is older than the javac tool in JDK1.8.0_60, you will get problems when you try to run it.
 
Nick Woods
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you guys for the answers. As Campbell Ritchie said, i just needed to add the java part in the beginning and then problem solved
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome

Actually Karan Pant said to add it at the beginning before I did.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!