find windows folder

Discussion in 'Java' started by Bjorn Borud, Jun 13, 2005.

  1. Bjorn Borud

    Bjorn Borud Guest

    ["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

    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
     
    Bjorn Borud, Jun 13, 2005
    #1
    1. Advertising

  2. 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
     
    massimo visman, Jun 13, 2005
    #2
    1. Advertising

  3. Bjorn Borud

    Lucy Guest

    "massimo visman" <> wrote in message
    news:_Ogre.3482$...
    > 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%
     
    Lucy, Jun 13, 2005
    #3
  4. Bjorn Borud

    Roland Guest

    On 13-6-2005 21:50, Lucy wrote:

    > "massimo visman" <> wrote in message
    > news:_Ogre.3482$...
    >
    >>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_/ /__/
    / \ /_/ / \
     
    Roland, Jun 13, 2005
    #4
  5. Bjorn Borud

    Lucy Guest

    "Roland" <> wrote in message
    news:42adeb2b$0$83537$4all.nl...
    > On 13-6-2005 21:50, Lucy wrote:
    >
    > > "massimo visman" <> wrote in message
    > > news:_Ogre.3482$...
    > >
    > >>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.
     
    Lucy, Jun 13, 2005
    #5
  6. 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, Jun 14, 2005
    #6
  7. 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
     
    Andrew Thompson, Jun 14, 2005
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. THY
    Replies:
    3
    Views:
    2,982
    Alvin Bruney
    Oct 16, 2003
  2. William LaMartin

    _vti_cnf folder in the bin folder-- a problem?

    William LaMartin, Nov 10, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    1,730
    Oliver
    Nov 10, 2003
  3. Wybo Dekker
    Replies:
    1
    Views:
    395
    Yukihiro Matsumoto
    Nov 15, 2005
  4. vdvorkin
    Replies:
    0
    Views:
    437
    vdvorkin
    Feb 10, 2011
  5. vdvorkin
    Replies:
    3
    Views:
    863
    vdvorkin
    Feb 14, 2011
Loading...

Share This Page