Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » accessing environment variables from a java application developed in eclipse
accessing environment variables from a java application developed in eclipse [message #229043] Tue, 02 May 2006 16:18 Go to next message
Eclipse UserFriend
Originally posted by: eclipseSubscribers.healthright.com

Hello All,
I have an issue that I hope you'll can throw some light on. I have been
online as well have asked some skilled friends if they know how to do this.
But have had no luck. If you'll dont know the answer please let me know
which might be an appropriate newsgroup to post to.

I need my java application to open a file and read its contents. I would
like to have the file location be read by the java application using the
environment vaiables. I read the environment variable using the following
line of code
String path = System.getProperty(environmentVariableName);
and
private static String environmentVariableName = "HR_RULE";

The file I want to read is titled c.xml and is inside of c:\\temp2 in my
windows xp environment
In the run launch configuration of the application I type
Run->Run and then in the environment TAB I do the following, click on New
and then I in the New Environment variable popup I write HR_RULE for the
name and C:\\\\temp2 as the value.

However when I run my application the environmentVariableName does not show
up correctly. i.e when I do a System.out.print( environmentVariableName) I
get a null for the environment variable name.

Any ideas on what I may be doing wrong ? or whats missing in my process for
accessing the environment variables.
Thanks in advance,
MN
Re: accessing environment variables from a java application developed in eclipse [message #229183 is a reply to message #229043] Wed, 03 May 2006 17:45 Go to previous messageGo to next message
Eclipse UserFriend
eshr wrote:
> Hello All,
> I have an issue that I hope you'll can throw some light on. I have been
> online as well have asked some skilled friends if they know how to do this.
> But have had no luck. If you'll dont know the answer please let me know
> which might be an appropriate newsgroup to post to.
>
> I need my java application to open a file and read its contents. I would
> like to have the file location be read by the java application using the
> environment vaiables. I read the environment variable using the following
> line of code
> String path = System.getProperty(environmentVariableName);
> and
> private static String environmentVariableName = "HR_RULE";
>
> The file I want to read is titled c.xml and is inside of c:\\temp2 in my
> windows xp environment
> In the run launch configuration of the application I type
> Run->Run and then in the environment TAB I do the following, click on New
> and then I in the New Environment variable popup I write HR_RULE for the
> name and C:\\\\temp2 as the value.

In theory you would add -DHR_RULE=<whatever> to the Arguments>VM
Arguments section if you wanted to do a System.getProperty(*).

Environment variables aren't normally accessible from java ... until
1.5.0 :-)

Check out System.getenv(String)

Later,
PW
Re: accessing environment variables from a java application developed in eclipse [message #229245 is a reply to message #229043] Thu, 04 May 2006 20:00 Go to previous message
Eclipse UserFriend
Originally posted by: eclipseSubscribers.healthright.com

Paul,
Thanks for the reply. I tried this and ti worked.
Thanks again.


"eshr" <eclipseSubscribers@healthright.com> wrote in message
news:e38eqs$e9a$1@utils.eclipse.org...
> Hello All,
> I have an issue that I hope you'll can throw some light on. I have been
> online as well have asked some skilled friends if they know how to do
> this. But have had no luck. If you'll dont know the answer please let me
> know which might be an appropriate newsgroup to post to.
>
> I need my java application to open a file and read its contents. I would
> like to have the file location be read by the java application using the
> environment vaiables. I read the environment variable using the following
> line of code
> String path = System.getProperty(environmentVariableName);
> and
> private static String environmentVariableName = "HR_RULE";
>
> The file I want to read is titled c.xml and is inside of c:\\temp2 in my
> windows xp environment
> In the run launch configuration of the application I type
> Run->Run and then in the environment TAB I do the following, click on New
> and then I in the New Environment variable popup I write HR_RULE for the
> name and C:\\\\temp2 as the value.
>
> However when I run my application the environmentVariableName does not
> show up correctly. i.e when I do a System.out.print(
> environmentVariableName) I get a null for the environment variable name.
>
> Any ideas on what I may be doing wrong ? or whats missing in my process
> for accessing the environment variables.
> Thanks in advance,
> MN
>
Previous Topic:Reusing Run as Java Project command
Next Topic:IPackageFragment.copy doesn't always update inner compilationunits?
Goto Forum:
  


Current Time: Fri Apr 25 22:12:15 EDT 2025

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

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

Back to the top