Results 1 to 5 of 5
  1. #1
    Hynesy is offline Member
    Join Date
    Dec 2010
    Posts
    2
    Rep Power
    0

    Default How to read Windows Version

    Hi All,

    As the title states I'm basically wanting to know if/how I can get Java to determine whether the user is running XP or Vista/7 and drop an icon into the correct default/desktop folders on XP and Vista/7.

    Cheers
    Hynesy

  2. #2
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    11

    Default

    Quote Originally Posted by Hynesy View Post
    Hi All,

    As the title states I'm basically wanting to know if/how I can get Java to determine whether the user is running XP or Vista/7 and drop an icon into the correct default/desktop folders on XP and Vista/7.

    Cheers
    Hynesy

    to get the os name you can use the following code

    Java Code:
    public class GetOSName {
    	public static void main(String[] args) {
    		Properties p = System.getProperties();
    		System.out.println(p.getProperty("os.name"));
    	}
    }

    and for your icon you can get the property called "user.home" and create a file in the "user.home" + Desktop.

  3. #3
    Hynesy is offline Member
    Join Date
    Dec 2010
    Posts
    2
    Rep Power
    0

    Default

    Quote Originally Posted by j2me64 View Post
    to get the os name you can use the following code

    Java Code:
    public class GetOSName {
    	public static void main(String[] args) {
    		Properties p = System.getProperties();
    		System.out.println(p.getProperty("os.name"));
    	}
    }

    and for your icon you can get the property called "user.home" and create a file in the "user.home" + Desktop.
    Awesome, cheers for the help j2me64, I'll give it a shot when I get to work today.

    Cheers
    Hynes

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    26

    Default

    the correct default/desktop folders on XP and Vista/7.
    Google found this utility
    Get the Windows Special Folders - Real's Java How-to

    db

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    26

    Default

    Also see the API for FileSystemView#getRoots()
    Java Code:
    for (File file : FileSystemView.getFileSystemView().getRoots()) {
      System.out.println(file.getAbsolutePath());
    }
    On Windows7, prints
    Java Code:
    C:\Users\Darryl\Desktop
    db

Similar Threads

  1. java -version pointing to older version
    By deepakts in forum New To Java
    Replies: 4
    Last Post: 05-06-2010, 09:59 AM
  2. Tomcat version for jdk 1.4.2
    By AnithaKarthik in forum Java Servlet
    Replies: 3
    Last Post: 11-09-2008, 01:21 PM
  3. Replies: 5
    Last Post: 10-17-2008, 02:13 PM
  4. using different JDK version in one IDE
    By happyknappy in forum New To Java
    Replies: 3
    Last Post: 09-02-2008, 02:10 PM
  5. to version
    By Alan in forum New To Java
    Replies: 2
    Last Post: 05-31-2007, 06:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •