GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes setting the variables in cmd or by Control Panel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "setting the variables in cmd or by Control Panel" Watch "setting the variables in cmd or by Control Panel" New topic
Author

setting the variables in cmd or by Control Panel

Tim Horton
Greenhorn

Joined: Aug 13, 2008
Posts: 6
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

Joined: Oct 02, 2003
Posts: 11350
    
  16

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 ]

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
daniel wright
Greenhorn

Joined: Aug 16, 2008
Posts: 7
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

Joined: Oct 13, 2005
Posts: 39044
    
  23
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

Joined: Oct 13, 2005
Posts: 39044
    
  23
. . . 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

Joined: Aug 16, 2008
Posts: 7
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

Joined: Aug 05, 2008
Posts: 347
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

Joined: Oct 13, 2005
Posts: 39044
    
  23
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

Joined: Aug 16, 2008
Posts: 7
hmmm ok i think i see where i went wrong..... thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: setting the variables in cmd or by Control Panel