🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.api
9 messages
9 total messages Started by Oliver Wed, 08 Jun 2005 13:29
retrieving standard program path from Windows
#204
Author: Oliver
Date: Wed, 08 Jun 2005 13:29
18 lines
1367 bytes
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
Re: retrieving standard program path from Windows
#205
Author: Shankar Unni
Date: Thu, 09 Jun 2005 01:00
9 lines
1449 bytes
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)?
Re: retrieving standard program path from Windows
#206
Author: Lori M Olson [TeamB]
Date: Thu, 09 Jun 2005 02:07
38 lines
2128 bytes
Shankar Unni wrote:
> 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)?

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

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
Re: retrieving standard program path from Windows
#207
Author: Oliver
Date: Thu, 09 Jun 2005 08:12
12 lines
1284 bytes
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
Re: retrieving standard program path from Windows
#208
Author: Lori M Olson [TeamB]
Date: Thu, 09 Jun 2005 22:18
39 lines
2008 bytes
Oliver wrote:
> 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
Re: retrieving standard program path from Windows
#209
Author: Shankar Unni
Date: Fri, 10 Jun 2005 23:10
9 lines
1418 bytes
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()
Re: retrieving standard program path from Windows
#210
Author: Oliver
Date: Mon, 13 Jun 2005 14:54
18 lines
1687 bytes
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@netscape.net> wrote:
>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()
Re: retrieving standard program path from Windows
#211
Author: Shankar Unni
Date: Mon, 13 Jun 2005 17:57
7 lines
1603 bytes
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.
Re: retrieving standard program path from Windows
#219
Author: Paul Nichols (TeamB)
Date: Thu, 15 Sep 2005 03:11
14 lines
1732 bytes
"Shankar Unni" <shankarunni@netscape.net> wrote in message
news:42adc921$1@newsgroups.borland.com...
> 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).
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads