Results 1 to 4 of 4
- 03-16-2009, 11:37 AM #1
Member
- Join Date
- Mar 2009
- Posts
- 4
- Rep Power
- 0
set environment variable in unix using java program
Hi,
I opened eclipse from a shell in Solaris. Now i am able to read the system environment variables using System.getenv() method. But now, i would like to set an environment variable back to shell using java itself.
Could any body help in this regard.
Thanks in Advance...
Raju
- 03-16-2009, 11:48 AM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
You can't. It wouldn't do any good, anyway, as it would only affect the shell in which the JVM is running.
If it is that, you want to be able to execute a system command, and ensure that it has the proper environment, then check out the API docs for ProcessBuilder.
- 03-16-2009, 11:55 AM #3
Member
- Join Date
- Mar 2009
- Posts
- 4
- Rep Power
- 0
If it effects the current shell where the JVM is running, it is fine for me.
Can you tell me how can i set that the env variable back to the shell where eclipse is launched?
Raju
- 03-16-2009, 12:26 PM #4
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
That is not the shell in which the current JVM is running. When Eclipse launches a project/application, it starts a new JVM, which, of course, gets it's own shell. And like I said, you can't do it, and even if you could it would only affect the current running JVM.
You might try using Runtime.exec/ProcessBuilder but it probably won't work, and success rates are liable to vary from platform to platform.
Similar Threads
-
can java program display icon on unix?
By java2008 in forum Advanced JavaReplies: 1Last Post: 10-06-2008, 07:33 AM -
how to run java app on windows in a cron like on unix
By rockie12 in forum Advanced JavaReplies: 7Last Post: 05-23-2008, 01:39 PM -
using java to login to unix
By dowell in forum Advanced JavaReplies: 4Last Post: 05-23-2008, 07:26 AM -
Passing Environment Variable in Eclipse Europa
By ajaymenon.k in forum EclipseReplies: 0Last Post: 11-19-2007, 10:08 AM -
Running java program with arguments in Unix"
By gvi in forum Advanced JavaReplies: 2Last Post: 11-08-2007, 07:01 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks