| View previous topic :: View next topic |
| Author |
Message |
Oliver Guest
|
Posted: Wed Jun 08, 2005 1:29 pm Post subject: retrieving standard program path from Windows |
|
|
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
|
Posted: Thu Jun 09, 2005 1:00 am Post subject: Re: retrieving standard program path from Windows |
|
|
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
|
Posted: Thu Jun 09, 2005 2:07 am Post subject: Re: retrieving standard program path from Windows |
|
|
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
|
Posted: Thu Jun 09, 2005 8:12 am Post subject: Re: retrieving standard program path from Windows |
|
|
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
|
Posted: Thu Jun 09, 2005 10:18 pm Post subject: Re: retrieving standard program path from Windows |
|
|
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
|
Posted: Fri Jun 10, 2005 11:10 pm Post subject: Re: retrieving standard program path from Windows |
|
|
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
|
Posted: Mon Jun 13, 2005 2:54 pm Post subject: Re: retrieving standard program path from Windows |
|
|
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
|
Posted: Mon Jun 13, 2005 5:57 pm Post subject: Re: retrieving standard program path from Windows |
|
|
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
|
Posted: Thu Sep 15, 2005 3:11 am Post subject: Re: retrieving standard program path from Windows |
|
|
"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 |
|
 |
|