System.getProperty("os.name")  //h获取名称
System.getProperty("os.version")  //版本号
System.getProperty("os.arch")   //架构
有没有获取安装路径的呢

解决方案 »

  1.   

    好像没有,我把properties全部打印出来了,没有发现。
      

  2.   

    user.dir>>User's current working directory
    系统安装路径好像没有
      

  3.   

    static Process process;    public static void main(String[] args) {
            try {
                String[] cmd = new String[] { "cmd.exe", "/c", "path" };
                process = Runtime.getRuntime().exec(cmd);
                InputStreamReader ir = new InputStreamReader(process
                        .getInputStream());
                BufferedReader br = new BufferedReader(ir);
                String line;
                String path="";
                while ((line = br.readLine()) != null){
                    path+=line;
                }
                System.out.println(path);
                path=path.substring(path.indexOf("=")+1).toLowerCase();
                
                String[] temp=path.split(";");
                for(int i=0;i<temp.length;i++){
                    if(temp[i].indexOf("windows")!=-1){
                        path=path.substring(0,temp[i].indexOf(":"));
                        break;
                    }
                }
                System.out.println(path);
            }        catch (java.io.IOException e) {
                System.err.println("IOException " + e.getMessage());
                e.printStackTrace();
            }
        }这样可以看出系统装在哪个盘上,但是遇到特殊情况也有漏洞,多加几道验证应该好点不知道ms-dos下有没有类似的命令,可以用runtime来执行,获取系统路径