find windows folder  
Author Message
massimo visman





PostPosted: 2005-6-13 22:34:00 Top

java-programmer, find windows folder Hi all! I have a question about Java and Windows systems...It's possible to
obtain the exact path of windows installation folder using Java functions? I
need this to be valid on different versions, from Win98 to WinXP

Thanks at all! Massimo


 
Bjorn Borud





PostPosted: 2005-6-13 22:25:00 Top

java-programmer >> find windows folder ["massimo visman" <email***@***.com>]
| Hi all! I have a question about Java and Windows systems...It's possible to
| obtain the exact path of windows installation folder using Java functions? I
| need this to be valid on different versions, from Win98 to WinXP

you could inspect the JVM system properties. specifically properties
like java.home. have a look at the Properties instance returned by
System.getProperties() on your various deployment platforms and see if
this at least can be used as a hint.

-Bj鴕n
 
Lucy





PostPosted: 2005-6-14 3:50:00 Top

java-programmer >> find windows folder
"massimo visman" <email***@***.com> wrote in message
news:_Ogre.3482$email***@***.com...
> Hi all! I have a question about Java and Windows systems...It's possible
to
> obtain the exact path of windows installation folder using Java functions?
I
> need this to be valid on different versions, from Win98 to WinXP
>
> Thanks at all! Massimo
>
It is %windir%


 
 
Roland





PostPosted: 2005-6-14 4:23:00 Top

java-programmer >> find windows folder On 13-6-2005 21:50, Lucy wrote:

> "massimo visman" <email***@***.com> wrote in message
> news:_Ogre.3482$email***@***.com...
>
>>Hi all! I have a question about Java and Windows systems...It's possible
>
> to
>
>>obtain the exact path of windows installation folder using Java functions?
>
> I
>
>>need this to be valid on different versions, from Win98 to WinXP
>>
>>Thanks at all! Massimo
>>
>
> It is %windir%
>
>
And in JRE 1.5 retrievable with:
System.getenv("windir");

In older JRE versions getenv(String) is deprecated and, when run, throws
an error, like:
java.lang.Error: getenv no longer supported, use properties and -D
instead: windir
--
Regards,

Roland de Ruiter
` ___ ___
`/__/ w_/ /__/
/ \ /_/ / \
 
 
Lucy





PostPosted: 2005-6-14 5:14:00 Top

java-programmer >> find windows folder
"Roland" <email***@***.com> wrote in message
news:42adeb2b$0$83537$email***@***.com...
> On 13-6-2005 21:50, Lucy wrote:
>
> > "massimo visman" <email***@***.com> wrote in message
> > news:_Ogre.3482$email***@***.com...
> >
> >>Hi all! I have a question about Java and Windows systems...It's possible
> >
> > to
> >
> >>obtain the exact path of windows installation folder using Java
functions?
> >
> > I
> >
> >>need this to be valid on different versions, from Win98 to WinXP
> >>
> >>Thanks at all! Massimo
> >>
> >
> > It is %windir%
> >
> >
> And in JRE 1.5 retrievable with:
> System.getenv("windir");
>

on older can you try ....run("echo %windir%")....

I forget the syntax exactly.


 
 
Andrew Thompson





PostPosted: 2005-6-14 20:06:00 Top

java-programmer >> find windows folder On Mon, 13 Jun 2005 14:33:30 GMT, massimo visman wrote:

> Hi all! I have a question about Java and Windows systems...

Why Windows specifically?

>..It's possible to
> obtain the exact path of windows installation folder using Java functions?

Why do you feel you need to know?

A lot of people misunderstand things like where to put their
own Java classes, or resource files like images and web pages
and such.
<http://www.physci.org/codes/javafaq.jsp#js>

In any case, you can get it this way..
<sscce>
public class JavaLocation {
public static void main(String[] args) {
Object o = new Object();
java.net.URL url =
o.getClass().getResource("/java/lang/Object.class");
// you can use the String methods to extract the path
System.out.println( url.toString() );
}
}
</sscce>

Note that yhis will throws security exceptions in unsigned
applets, unless the user is running IE and using the MSVM.

HTH

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
 
 
Andrew Thompson





PostPosted: 2005-6-14 21:10:00 Top

java-programmer >> find windows folder On Tue, 14 Jun 2005 12:06:06 GMT, Andrew Thompson wrote:

> A lot of people misunderstand things like where to put their
> own Java classes, or resource files like images and web pages
> and such.
> <http://www.physci.org/codes/javafaq.jsp#js>

Sorry, that link should have been.
<http://www.physci.org/codes/javafaq.jsp#path>

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane