Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » environment variables
environment variables [message #29962] Tue, 13 May 2003 15:00 Go to next message
Eclipse UserFriend
I would like to get a hold of the environment variables that are part of the
Eclipse process. Not just one particular variable, but all of them.
Unfortunately java does not provide a mechanism for getting all of them. So
I was hoping that the Eclipse core platform might have this functionality
since I think it is something that will be useful to many contributors.

Why do I think this functionality will be so useful? Well, this has to do
with the fact that many plugins launch programs, and it is these programs
that may have a dependency on the environment. So this is an integration
issue.

Here is a specific example of how I ran into this. I am working on a plugin
to support a custom programming language. When doing either a normal run or
a debug run, I launch my language as a separate process, the way the JDT
does with its wire protocol. Now, this running process needs to have a
proper environment because it may want to create other subprocess that
depend on some environment variables for their execution (e.g. for
authorization, or for paths).

Here is our full model for handling environment variables, and I think it is
quite sensible and that it would make sense to many others who are
contributing plugins for othere programming languages.

1) Allow the user to add environment variables in the launch configuration
2) Perhaps also allow environment customisations in the preferences so that
it applies to all run of that programming language.

Then when it is time to run:

3) Grab the environment of the Eclipse process itself
4) Add to this the extra environment variables from the prefernces,
replacing variables in the Eclipse environment with those from the
preference in case of a collision.
5) Add to this the extra environment variables from the launch
configuration, replacing variables in the Eclipse environment or from the
preferences with those from the launch configuration in case of a collision.

Note that we do not provide a way for a variable in the Eclipse environment
to be simply removed. We only provide an override mechanism. I believe this
is plenty good.

So, is there a way to get the current environment, and if not might this be
considered for addition to the core platform?

Thanks!

Patrick Baker
Re: environment variables [message #32344 is a reply to message #29962] Wed, 14 May 2003 14:40 Go to previous messageGo to next message
Eclipse UserFriend
Okay, so nobody cares about this:(

I have gone ahead and written my own version, but I still think that this
should be included in eclipse core platform since those developers
responsible for it have more machines to test the code on than I. For
example, I don't know anything about the Mac, so I don't know how to handle
that platform. Here is the code (I actually started off with something I got
off the net http://www.rgagnon.com/javadetails/java-0150.html):

protected static String[] getSystemEnvironment()
{
String[] Result = null;
try
{
String OSname = System.getProperty("os.name").toLowerCase();
String command = null;

if (OSname.indexOf("windows 9") > -1)
command = "command.com /c set";
else if ((OSname.indexOf("nt") > -1) || (OSname.indexOf("windows")
> -1))
command = "cmd.exe /c set";
else
command = "env";

Process p = Runtime.getRuntime().exec(command);

BufferedReader br = new BufferedReader(new
InputStreamReader(p.getInputStream()));
Vector variables = new Vector();
String line;
while((line = br.readLine()) != null)
variables.add(line);

Result = new String[variables.size()];
Result = (String[]) variables.toArray(Result);
}
catch (Throwable t)
{
}
return Result;
}


--
-----------------------------------------------
Patrick Baker
Stilo Corporation
pbaker@omnimark.com

"Hail, twin companionship, children of Mars."

This message, including any attachments, is for the sole use of the
intended recipient(s) and may contain confidential and privileged
information. Any unauthorized review, use, disclosure, copying, or
distribution is strictly prohibited. If you are not the intended
recipient(s) please contact the sender by reply email and destroy
all copies of the original message and any attachments.

"Patrick Baker" <pbaker@ca.stilo.com> wrote in message
news:b9rfdb$dif$1@rogue.oti.com...
> I would like to get a hold of the environment variables that are part of
the
> Eclipse process. Not just one particular variable, but all of them.
> Unfortunately java does not provide a mechanism for getting all of them.
So
> I was hoping that the Eclipse core platform might have this functionality
> since I think it is something that will be useful to many contributors.
>
> Why do I think this functionality will be so useful? Well, this has to do
> with the fact that many plugins launch programs, and it is these programs
> that may have a dependency on the environment. So this is an integration
> issue.
>
> Here is a specific example of how I ran into this. I am working on a
plugin
> to support a custom programming language. When doing either a normal run
or
> a debug run, I launch my language as a separate process, the way the JDT
> does with its wire protocol. Now, this running process needs to have a
> proper environment because it may want to create other subprocess that
> depend on some environment variables for their execution (e.g. for
> authorization, or for paths).
>
> Here is our full model for handling environment variables, and I think it
is
> quite sensible and that it would make sense to many others who are
> contributing plugins for othere programming languages.
>
> 1) Allow the user to add environment variables in the launch configuration
> 2) Perhaps also allow environment customisations in the preferences so
that
> it applies to all run of that programming language.
>
> Then when it is time to run:
>
> 3) Grab the environment of the Eclipse process itself
> 4) Add to this the extra environment variables from the prefernces,
> replacing variables in the Eclipse environment with those from the
> preference in case of a collision.
> 5) Add to this the extra environment variables from the launch
> configuration, replacing variables in the Eclipse environment or from the
> preferences with those from the launch configuration in case of a
collision.
>
> Note that we do not provide a way for a variable in the Eclipse
environment
> to be simply removed. We only provide an override mechanism. I believe
this
> is plenty good.
>
> So, is there a way to get the current environment, and if not might this
be
> considered for addition to the core platform?
>
> Thanks!
>
> Patrick Baker
>
>
Re: environment variables [message #34060 is a reply to message #32344] Thu, 15 May 2003 15:51 Go to previous message
Eclipse UserFriend
Originally posted by: genadyb.inter.net.il

See https://bugs.eclipse.org/bugs/show_bug.cgi?id=33606
You can find there a reference to a piece of code that does exactly what
you need.

Genady

Patrick Baker wrote:
> Okay, so nobody cares about this:(
>
> I have gone ahead and written my own version, but I still think that this
> should be included in eclipse core platform since those developers
> responsible for it have more machines to test the code on than I. For
> example, I don't know anything about the Mac, so I don't know how to handle
> that platform. Here is the code (I actually started off with something I got
> off the net http://www.rgagnon.com/javadetails/java-0150.html):
>
> protected static String[] getSystemEnvironment()
> {
> String[] Result = null;
> try
> {
> String OSname = System.getProperty("os.name").toLowerCase();
> String command = null;
>
> if (OSname.indexOf("windows 9") > -1)
> command = "command.com /c set";
> else if ((OSname.indexOf("nt") > -1) || (OSname.indexOf("windows")
>
>>-1))
>
> command = "cmd.exe /c set";
> else
> command = "env";
>
> Process p = Runtime.getRuntime().exec(command);
>
> BufferedReader br = new BufferedReader(new
> InputStreamReader(p.getInputStream()));
> Vector variables = new Vector();
> String line;
> while((line = br.readLine()) != null)
> variables.add(line);
>
> Result = new String[variables.size()];
> Result = (String[]) variables.toArray(Result);
> }
> catch (Throwable t)
> {
> }
> return Result;
> }
>
>
> --
> -----------------------------------------------
> Patrick Baker
> Stilo Corporation
> pbaker@omnimark.com
>
> "Hail, twin companionship, children of Mars."
>
> This message, including any attachments, is for the sole use of the
> intended recipient(s) and may contain confidential and privileged
> information. Any unauthorized review, use, disclosure, copying, or
> distribution is strictly prohibited. If you are not the intended
> recipient(s) please contact the sender by reply email and destroy
> all copies of the original message and any attachments.
>
> "Patrick Baker" <pbaker@ca.stilo.com> wrote in message
> news:b9rfdb$dif$1@rogue.oti.com...
>
>>I would like to get a hold of the environment variables that are part of
>
> the
>
>>Eclipse process. Not just one particular variable, but all of them.
>>Unfortunately java does not provide a mechanism for getting all of them.
>
> So
>
>>I was hoping that the Eclipse core platform might have this functionality
>>since I think it is something that will be useful to many contributors.
>>
>>Why do I think this functionality will be so useful? Well, this has to do
>>with the fact that many plugins launch programs, and it is these programs
>>that may have a dependency on the environment. So this is an integration
>>issue.
>>
>>Here is a specific example of how I ran into this. I am working on a
>
> plugin
>
>>to support a custom programming language. When doing either a normal run
>
> or
>
>>a debug run, I launch my language as a separate process, the way the JDT
>>does with its wire protocol. Now, this running process needs to have a
>>proper environment because it may want to create other subprocess that
>>depend on some environment variables for their execution (e.g. for
>>authorization, or for paths).
>>
>>Here is our full model for handling environment variables, and I think it
>
> is
>
>>quite sensible and that it would make sense to many others who are
>>contributing plugins for othere programming languages.
>>
>>1) Allow the user to add environment variables in the launch configuration
>>2) Perhaps also allow environment customisations in the preferences so
>
> that
>
>>it applies to all run of that programming language.
>>
>>Then when it is time to run:
>>
>>3) Grab the environment of the Eclipse process itself
>>4) Add to this the extra environment variables from the prefernces,
>>replacing variables in the Eclipse environment with those from the
>>preference in case of a collision.
>>5) Add to this the extra environment variables from the launch
>>configuration, replacing variables in the Eclipse environment or from the
>>preferences with those from the launch configuration in case of a
>
> collision.
>
>>Note that we do not provide a way for a variable in the Eclipse
>
> environment
>
>>to be simply removed. We only provide an override mechanism. I believe
>
> this
>
>>is plenty good.
>>
>>So, is there a way to get the current environment, and if not might this
>
> be
>
>>considered for addition to the core platform?
>>
>>Thanks!
>>
>>Patrick Baker
>>
>>
>
>
>
Previous Topic:Newbie Plugin Builder
Next Topic:Howto add a menu item to the Source menu of the JavaEditor?
Goto Forum:
  


Current Time: Sat Oct 25 01:56:39 EDT 2025

Powered by FUDForum. Page generated in 0.03831 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top