• Post Reply Bookmark Topic Watch Topic
  • New Topic

Setting Enviromental Variables  RSS feed

 
Paul Wyatt
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
After installing JDK, I extended my system path to include C:\Program Files\Java\jdk1.8.0\bin.
However, javac is only recognised if im in directory C: but that doesn't apply to the Java (run) command
which works when Im in the sub-directory that has my .class file. Is there a way to make javac work when Im in a sub-directory?

Thanks
 
Campbell Ritchie
Marshal
Posts: 56562
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure I quote understand the question. What goes wrong? Please post the error messages.

What output do you get when you try the following four instructions at the command line?CLASSPATH should return nothing.
 
Paul Wyatt
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Campbell - Thanks for your response
My Source Code is in the folder C:\Java\. If I type javac at the command prompt while this is the current directory, I get this error message:

'javac' is not recognized as an internal or external command,
operable program or batch file.

%PATH% gives me:

C:\Java>echo %PATH%
C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;C:\Program Files\Common Files\Microsoft
Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Fil
es\ArcSoft\Bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\ATI Technologies\ATI.ACE\C
ore-Static;C:\Program Files (x86)\Windows Live\Shared;C:\Windows\System32\WindowsPowerShell\v1.0\;C:Program Files\Java\j
dk1.8.0\bin

C:\Java>echo %CLASSPATH%
returns %CLASSPATH%

C:\Java>javac -version gives me:

'javac' is not recognized as an internal or external command,
operable program or batch file.


C:\Java>java -version gives me:

java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)


C:\>javac -version gives me:
javac 1.8.0

My question was: can the javac command be recognised when entered whilst a sub directory of C:\ is active as it can for the java command?
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Wyatt wrote:Hello
After installing JDK, I extended my system path to include C:\Program Files\Java\jdk1.8.0\bin.

No you haven't. Look carefully at your PATH variable.
The reason it ran java is becuase there is a java.exe in either C:\Windows\system32 or C:\Windows. It's not running anything from your JDK bin directory.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12564
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i didn't see it mentioned, but just in case...if you update your PATH variable, you have to open a new command window for the changes to be picked up. any cmd window already open will NOT see said changes.
 
Campbell Ritchie
Marshal
Posts: 56562
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You also need to write the new Java® installation folder before anywhere else which might contain the java tool.
 
Paul Wyatt
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks All for your reponses.
Joanne
So why is it that I can have the dir C:/Java selected and
1) Java.exe is found when its in either C:\Windows or C:\Windows\System32 (i.e it works despite not being in either the current directory or any of its sub-directories)
2) javac is not found when its located in a specified path as well, and also not in the current or sub directories?

Fred
A new CMD session was established after the path update, but javac is only found if the route directory (C:\) is selected at the prompt.

Campbell
If I place the JDK installation path as the first entry would that resolve the issue without disrupting other operations ?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66306
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The text you added to the PATH variable is wrong.
 
Campbell Ritchie
Marshal
Posts: 56562
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be specific in your spelling. When you are programming, the computer will behave differently for the slightest difference in spelling. It is one of those things you will have to get used to.
There is a difference between C:Something and C:/Something and C;\Something.
 
Paul Wyatt
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Bear
That has resolved the problem
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!