BabyFace
asked on
executing set command
Hi,
I'm using windows and would like to set some environment variables from my java program via the set command. The only problem is that I don't know how to invoke it directly from my program. I've look at the exec method of the Runtime class but it failed to create the process. I do not wan't to call a batch file to run the set command.
Thanks.
I'm using windows and would like to set some environment variables from my java program via the set command. The only problem is that I don't know how to invoke it directly from my program. I've look at the exec method of the Runtime class but it failed to create the process. I do not wan't to call a batch file to run the set command.
Thanks.
ASKER
"cmd /C set classpath=ccc"
when this command is executed through the Runtime instance I don't see it in the environment when I type:
set c
Thanks
when this command is executed through the Runtime instance I don't see it in the environment when I type:
set c
Thanks
Calling set only changes the environment for that shell instance. To demonstrate this, open two DOS windows and set an environment var in one. Then check the env in the other and you'll see it's not set there. And even if you open a new DOS window it won't be set there either.
I don't know of a way to do what you require.
I don't know of a way to do what you require.
ASKER
Clarification:
I only require that the environment variable be set in the instance of the DOS window where the class file was ran.
When I open a new DOS window, then run my program (it tell the Runtime to execute something like "cmd /C set classpath=ccc".) The env. var. are not set...
I only require that the environment variable be set in the instance of the DOS window where the class file was ran.
When I open a new DOS window, then run my program (it tell the Runtime to execute something like "cmd /C set classpath=ccc".) The env. var. are not set...
problem is that the 'cmd /C set ...' starts new shell (cmd)
ASKER
can you suggest a work around?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
> I only require that the environment variable be set in
> the instance of the DOS window where the class
> file was ran.
Don't know of any way to do that.
What exactly is it you are trying to do?
> the instance of the DOS window where the class
> file was ran.
Don't know of any way to do that.
What exactly is it you are trying to do?
ASKER
It's ok.
I guess i'll use batch files or something.
Thanks anyway.
I guess i'll use batch files or something.
Thanks anyway.
How does using a batch file affect the env of the current DOS window?
"cmd /C set var=xxx"