BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

retrieving standard program path from Windows

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder JavaAPI
View previous topic :: View next topic  
Author Message
Oliver
Guest





PostPosted: Wed Jun 08, 2005 1:29 pm    Post subject: retrieving standard program path from Windows Reply with quote




Hi,

at the moment im trying to retrieve the standard program path ("C:Programme" or "C:Program Files" or ... itīs language dependent) from Windows 2000 with my Java program (JDK 1.5).
Does somebody have an idea?

I had a look at java.lang.System, here i get the user.dir (working directory) by

String s = "";
Properties P = java.lang.System.getProperties();
s = P.getProperty("user.dir");
return s;

but this is not exactly what i want.

thanks

Oliver
Back to top
Shankar Unni
Guest





PostPosted: Thu Jun 09, 2005 1:00 am    Post subject: Re: retrieving standard program path from Windows Reply with quote



Oliver wrote:

Quote:
at the moment im trying to retrieve the standard program path ("C:Programme"
or "C:Program Files" or ... itīs language dependent) from Windows 2000
with my Java program (JDK 1.5).

Have you tried looking for an environment variable (or property) called
"ProgramFiles" or "PROGRAMFILES" (depending on which sort of shell you
start your program from)?

Back to top
Lori M Olson [TeamB]
Guest





PostPosted: Thu Jun 09, 2005 2:07 am    Post subject: Re: retrieving standard program path from Windows Reply with quote



Shankar Unni wrote:
Quote:
Oliver wrote:

at the moment im trying to retrieve the standard program path
("C:Programme"

or "C:Program Files" or ... itīs language dependent) from Windows 2000
with my Java program (JDK 1.5).

Have you tried looking for an environment variable (or property) called
"ProgramFiles" or "PROGRAMFILES" (depending on which sort of shell you
start your program from)?

[url]http://java.sun.com/j2se/1.5.0/docs/api/java/lang/System.html#getenv(java.lang.String[/url])

On my Windows 2003 Server, the environment variable is "ProgramFiles"

Note that System.getenv() was deprecated from JDK 1.1 to JDK 1.4,
resurfacing in JDK 1.5.

--

Regards,

Lori Olson [TeamB]

------------

Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.

Google Advanced Newsgroup Search
http://www.google.ca/advanced_group_search
Other Newsgroup Searches:
http://www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
http://www.visi.com/~gyles19/fom-serve/cache/1.html

Back to top
Oliver
Guest





PostPosted: Thu Jun 09, 2005 8:12 am    Post subject: Re: retrieving standard program path from Windows Reply with quote


Hello,

ok, many thanks.

Quote:
Note that System.getenv() was deprecated from JDK 1.1 to JDK 1.4, >resurfacing in JDK 1.5.

Ok, now i have one question still: i have another (similar) project in JDK 1.4. Is there another possibility in 1.4 to retrieve the ProgramFiles Dir?

regards

Oliver


Back to top
Lori M Olson [TeamB]
Guest





PostPosted: Thu Jun 09, 2005 10:18 pm    Post subject: Re: retrieving standard program path from Windows Reply with quote

Oliver wrote:
Quote:
Hello,

ok, many thanks.


Note that System.getenv() was deprecated from JDK 1.1 to JDK 1.4,
resurfacing in JDK 1.5.


Ok, now i have one question still: i have another (similar) project
in JDK 1.4. Is there another possibility in 1.4 to retrieve the
ProgramFiles Dir?

regards

Oliver


Not without the use of JNI.

--

Regards,

Lori Olson [TeamB]

------------

Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.

Google Advanced Newsgroup Search
http://www.google.ca/advanced_group_search
Other Newsgroup Searches:
http://www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
http://www.visi.com/~gyles19/fom-serve/cache/1.html

Back to top
Shankar Unni
Guest





PostPosted: Fri Jun 10, 2005 11:10 pm    Post subject: Re: retrieving standard program path from Windows Reply with quote

Lori M Olson [TeamB] wrote:

Quote:
Not without the use of JNI.

Or by the classic dodge of exec'ing a helper program to write out the
values of environment variables:

Process p = Runtime.getRuntim().exec("cmd /c echo '%PROGRAMFILES%'");
// Read the output from p.getOutputStream()

Back to top
Oliver
Guest





PostPosted: Mon Jun 13, 2005 2:54 pm    Post subject: Re: retrieving standard program path from Windows Reply with quote


Hello,

thank you both. I have one little remaining question: how can i read from the OutputStream? (toString() returns the address of the object, but where is the content?)

Oliver


Shankar Unni <shankarunni (AT) netscape (DOT) net> wrote:
Quote:
Lori M Olson [TeamB] wrote:

Not without the use of JNI.

Or by the classic dodge of exec'ing a helper program to write out the
values of environment variables:

Process p = Runtime.getRuntim().exec("cmd /c echo '%PROGRAMFILES%'");
// Read the output from p.getOutputStream()


Back to top
Shankar Unni
Guest





PostPosted: Mon Jun 13, 2005 5:57 pm    Post subject: Re: retrieving standard program path from Windows Reply with quote

Oliver wrote:

Quote:
thank you both. I have one little remaining question:
how can i read from the OutputStream?

Whoops. I meant Process.getInputStream(), which contains the output of
the process. Read from it like any other InputStream.

Back to top
Paul Nichols (TeamB)
Guest





PostPosted: Thu Sep 15, 2005 3:11 am    Post subject: Re: retrieving standard program path from Windows Reply with quote


"Shankar Unni" <shankarunni (AT) netscape (DOT) net> wrote

Quote:
Oliver wrote:

thank you both. I have one little remaining question:
how can i read from the OutputStream?

Whoops. I meant Process.getInputStream(), which contains the output of
the process. Read from it like any other InputStream.

Once you get the InputStream class, you read it as you would any other
InputStream. I would recommend you place it in a BufferedStream type class
however (like BufferedReader).





Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder JavaAPI All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.