Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » how to access environment variables form a launch configuration
how to access environment variables form a launch configuration [message #223332] Mon, 30 January 2006 12:24 Go to next message
Eclipse UserFriend
Originally posted by: hannes.2horns.com

Group,

I had asked this question already on the eclipse.platform mailing list, but
I finally reckoned that was just not the right place for it.
So I'm reposting it here.

I wonder whether it is possible to access environment variables from within
a launch configuration.

e.g. I'd like to use an environment variable when specifying arguments for
the java program to be launched.

e.g. -prefs=$USER/.prefs

where $USER is an environment variable set outside of eclipse.

The way I tried it is not working - duh. How would I do this (if possible)
correctly?

Thx. a lot,
H.
Re: how to access environment variables form a launch configuration [message #223348 is a reply to message #223332] Mon, 30 January 2006 13:10 Go to previous messageGo to next message
Eclipse UserFriend
Prove me wrong but a call to System.getProperty should do the trick?!
Which approach did you used and failed with?
Re: how to access environment variables form a launch configuration [message #223356 is a reply to message #223348] Mon, 30 January 2006 13:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hannes.2horns.com

Sorry - wasn't too clear about what I was trying to do, was I?

I'm trying to introduce shared launch configs, such as the following snippet
shows:

<?xml version="1.0" encoding="UTF-8"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH"
value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="main"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS"
value="-path $WORK_HOME"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS"
value="-Xverify:none -Xms12m -Xmx256m"/>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables"
value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY"
value=$WORK_HOME/>
</launchConfiguration>

Herein, $WORK_HOME is different for every developer.
Unfortunately, this - as shown above - is not working.

My question was whether this possible - and if so, how to do it right.

H.

Ricky wrote:
> Prove me wrong but a call to System.getProperty should do the trick?!
> Which approach did you used and failed with?
Re: how to access environment variables form a launch configuration [message #223369 is a reply to message #223356] Mon, 30 January 2006 15:34 Go to previous messageGo to next message
Eclipse UserFriend
Cool, a few days back I looked at launching and implemented a Launcher and
never get across such an xml file.

I outline what I did and I am sure that it will not be of any use to your
setup:

I declared an LaunchDelegate, LaunchConfigurationType and a
launchConfigurationTabGroups together with a LaunchConfigurationTab. In
the tab it is possible to add values to the launch configuration with
setDefaults and performApply, both working on a
LaunchConfigurationWorkingCopy. My coworker also utilized some java
specific classes to exploid their behavior. I cant ask him in the next few
days but I think it was something with
AbstractJavaLaunchConfigurationDelegate. But I have to admit we only
fooled around with this.

The xml file looks interesting but maybe it is possible to add the values
programmatically?

Ricky
Re: how to access environment variables from a launch configuration [message #223382 is a reply to message #223369] Mon, 30 January 2006 17:02 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hannes.2horns.com

Ricky,

this 'xml-style' file (extension .lanuch) is what's being created by Eclipse
for you (and placed in your project folder, where your .project and
..classpath files reside), if you declared it "shared" ('Common' tab on
launch config dialog).
I was hoping I could use environment variables in these .lanuch files, and I
was also hoping that there was somebody out there that knew how to do it (if
it was possible in the first place).

H.

Ricky wrote:
> Cool, a few days back I looked at launching and implemented a
> Launcher and never get across such an xml file.
>
> I outline what I did and I am sure that it will not be of any use to
> your setup:
>
> I declared an LaunchDelegate, LaunchConfigurationType and a
> launchConfigurationTabGroups together with a LaunchConfigurationTab.
> In the tab it is possible to add values to the launch configuration
> with setDefaults and performApply, both working on a
> LaunchConfigurationWorkingCopy. My coworker also utilized some java
> specific classes to exploid their behavior. I cant ask him in the
> next few days but I think it was something with
> AbstractJavaLaunchConfigurationDelegate. But I have to admit we only
> fooled around with this.
>
> The xml file looks interesting but maybe it is possible to add the
> values programmatically?
>
> Ricky
Re: how to access environment variables form a launch configuration [message #223390 is a reply to message #223332] Mon, 30 January 2006 18:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jaredburns.no.spam.acm.org

Launch configuration support their own kind of variables. These can be
contributed via extension and the platform also provides some -
including a variable which you can use to reference environment vars.

In the launch configuration dialog, click on the "Variables..." button
next to a field. Select "env_var" and enter the name of the variable in
the "Arguments" field. This will insert a variable reference like
"${env_var:HOME}" into whatever text field you're configuring.

- Jared

Hans Horn wrote:
> Group,
>
> I had asked this question already on the eclipse.platform mailing list, but
> I finally reckoned that was just not the right place for it.
> So I'm reposting it here.
>
> I wonder whether it is possible to access environment variables from within
> a launch configuration.
>
> e.g. I'd like to use an environment variable when specifying arguments for
> the java program to be launched.
>
> e.g. -prefs=$USER/.prefs
>
> where $USER is an environment variable set outside of eclipse.
>
> The way I tried it is not working - duh. How would I do this (if possible)
> correctly?
>
> Thx. a lot,
> H.
>
>
Re: how to access environment variables form a launch configuration [message #223398 is a reply to message #223390] Mon, 30 January 2006 19:13 Go to previous message
Eclipse UserFriend
Originally posted by: hannes.2horns.com

Jared,

That was exactly what I was looking for!

<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS"
value="-path ${env_var:WORK_HOME}"/>
indeed did the trick!

thx a gazillion!
H.

Jared Burns wrote:
> Launch configuration support their own kind of variables. These can be
> contributed via extension and the platform also provides some -
> including a variable which you can use to reference environment vars.
>
> In the launch configuration dialog, click on the "Variables..." button
> next to a field. Select "env_var" and enter the name of the variable
> in the "Arguments" field. This will insert a variable reference like
> "${env_var:HOME}" into whatever text field you're configuring.
>
> - Jared
>
> Hans Horn wrote:
>> Group,
>>
>> I had asked this question already on the eclipse.platform mailing
>> list, but I finally reckoned that was just not the right place for
>> it. So I'm reposting it here.
>>
>> I wonder whether it is possible to access environment variables from
>> within a launch configuration.
>>
>> e.g. I'd like to use an environment variable when specifying
>> arguments for the java program to be launched.
>>
>> e.g. -prefs=$USER/.prefs
>>
>> where $USER is an environment variable set outside of eclipse.
>>
>> The way I tried it is not working - duh. How would I do this (if
>> possible) correctly?
>>
>> Thx. a lot,
>> H.
Previous Topic:JDT Debug mark a specific line
Next Topic:dollar sign in class names confuse editor
Goto Forum:
  


Current Time: Mon Sep 15 00:21:03 EDT 2025

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

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

Back to the top