This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setting the variables in cmd or by Control Panel

 
Tim Horton
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all
i am totally new to java and i have a question :

i set some variable such at this by cmd ... ok .... but then I close the cmd windows, they no longer work and also when I go to Environment Varibales of control panel , there is no effect of these commnads there ...
what is the problem ? should it be like this ...
thank you
 
fred rosenberger
lowercase baba
Bartender
Posts: 12089
29
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you execute this in a cmd window, they are lost when that window closes, and they do not transfer to any other cmd window.

if you update your environment variables, you have to open a new cmd window AFTER you have saved them for them to be visible. any already existing cmd window is not effected.

if you want them to be permanent (and I'm assuming Windows here), right-click on "My Computer". go to the 'advanced' tab, and click 'environment variables'. You can then either edit or add the variable to the 'system variables', which will then be there for anyone on your computer, or 'user variables', if it's only for the current log-on id.
[ August 13, 2008: Message edited by: fred rosenberger ]
 
daniel wright
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah im having a problem too... i set the path to where it can find javac but when i close the window and try it again it still gives me the same message.... i got back to variables and the path is set... anyone have a clue?
 
Campbell Ritchie
Sheriff
Posts: 48454
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch, both of you

What error message are you getting? The message you get when your PATH is set incorrectly reads something like

"javac is not recognized as a program file or something else" on Windows or

"no javac in /usr /usr/bin /bin /etc etc etc" on Linux.

Please invoke "java -version" and "javac -version" and you should get something starting with the version number. It is a lot better if they are the same version!
 
Campbell Ritchie
Sheriff
Posts: 48454
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. . . and Fred has already told you that setting the PATH on a window is only valid for the lifetime of that window; if you open another window (even before closing the other window) it won't have the PATH set.

This Java Tutorial page has a link to the installation instructions for setting the PATH permanently (don't believe them when they call it "optional"). For Linux you ought to search a Linux forum; what you have to do varies from terminal to terminal.
 
daniel wright
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no im still getting the one as if i didnt set path at all...." 'javac' is not recognized as an interna or external command operable program or batch file. i check the variables and they are there
 
Gamini Sirisena
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For javac..

You should set it as follows..

set path=WhereEverYourJdkIsInstalled\bin;%path%

(the %path% bit to keep whatever in the path variable earlier)

make sure you don't keep spaces around the =

If this doesn't work it would help to provide more information to the cowboys here.
Send the set command you are issuing and the out put of a "echo %path%" after that.
 
Campbell Ritchie
Sheriff
Posts: 48454
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Gamini Sirisena:
For javac..

You should set it as follows..

set path=WhereEverYourJdkIsInstalled\bin;%path%

(the %path% bit to keep whatever in the path variable earlier)

make sure you don't keep spaces around the =

If this doesn't work it would help to provide more information to the cowboys here.
Send the set command you are issuing and the out put of a "echo %path%" after that.
"Cowboys?" Ranchers, please!!

That instruction will work for Windows; please check whether it is case-sensitive or (as I think is the case) case-insensitive. You usually find your PATH entry begins with the drive letter (commonly C) for Windows or / for *nix. The PATH entry for Java always ends with bin. So on Windows you would probably write
set PATH=C:\Program Files\Java\jdk1.6.0_07\bin;%PATH%
depending where you installed Java. If that doesn't work try " after the = and " before ;%PATH% because of the space after Program.

You are however far better off setting the PATH permanently; I have already given you a link.
 
daniel wright
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmmm ok i think i see where i went wrong..... thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic