Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2009
    Rep Power

    Default Unable to detect OS name

    I have installed the Windows 7 on my PC. When i tried to get the

    OS name using java (jre 1.6), i am getting OS name as Windows

    vista. This makes problems for me as i badly need the OS name

    programmatically for my application to run. So, i want to know

    anything i need to do get the exact OS name.

    Actually, i have to set one value as "false" in my application if

    OS is Windows 7 else "true". This has to done at runtime.

    I am trying to get OS name with following statement:

    String os = System.getProperty("");
    System.out.println("OS: "+os);

    This code give OS name as "Wndows Vista" instaed it should give

    "Windows 7".
    Any help would be greatly appreciated.

  2. #2
    CodesAway's Avatar
    CodesAway is offline Senior Member
    Join Date
    Sep 2009
    Rep Power


    Do you have the latest update, JRE 1.6_17?

    Also, from a bug report I saw, it seems that the OS version can be used.

    Java Code:
    public static void main(String[] args) {
    	System.out.println("OS: " + System.getProperty(""));
    	System.out.println("Version: " + System.getProperty("os.version"));

    I'm running Windows Vista, and I get the following output:

    Java Code:
    OS: Windows Vista
    Version: 6.0

    It seems that in Windows 7, the Version is 6.1. So, you could check the version. If it's Vista with version 6.0, then it's Vista; if it has version 6.1, it's Windows 7.
    CodesAway -
    writing tools that make writing code a little easier

Similar Threads

  1. Detect the ENTER key being pressed
    By aaronfsimons in forum New To Java
    Replies: 12
    Last Post: 05-16-2009, 09:48 PM
  2. How to detect double click with a JFrame
    By Jary316 in forum New To Java
    Replies: 3
    Last Post: 01-05-2009, 09:39 PM
  3. Detect when the user scrolls a text control
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-25-2008, 03:21 PM
  4. Detect loading of ImageIcon from URL?
    By barkster in forum Java Applets
    Replies: 1
    Last Post: 01-29-2008, 08:04 PM
  5. Detect TimeOut in a HttpURL Connection
    By Ed in forum Advanced Java
    Replies: 2
    Last Post: 07-02-2007, 05:29 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