find windows folder

B

Bjorn Borud

["massimo visman" <[email protected]>]
| 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ørn
 
M

massimo visman

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
 
L

Lucy

massimo visman said:
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%
 
R

Roland

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_/ /__/
/ \ /_/ / \
 
A

Andrew Thompson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top