没有
想必兄台看过笑傲江湖吧 想要修炼上乘神功 需要把以前的功夫全部废掉 不然很容易经脉错乱 走火入魔同样的道理 java 不是 c

解决方案 »

  1.   

    我说没有其实是想说java不想让c牵扯太多
    java中 System.getenv(); 可得到一个Map对象,不知道什么应用中需要得到这个
      

  2.   

    System.getProperty
    System.setProperty
      

  3.   

    哪去修改一下吧,或者是自己查查java API就可以了
    import java.io.*;
    import java.util.*;public class ReadEnv {
     public static Properties getEnvVars() throws Throwable {
      Process p = null;
      Properties envVars = new Properties();
      Runtime r = Runtime.getRuntime();
      String OS = System.getProperty("os.name").toLowerCase();
      // System.out.println(OS);
      if (OS.indexOf("windows 9") > -1) {
        p = r.exec( "command.com /c set" );
        }
      else if ( (OS.indexOf("nt") > -1)
             || (OS.indexOf("windows 20") > -1 )
             || (OS.indexOf("windows xp") > -1) ) {
        // thanks to JuanFran for the xp fix!
        p = r.exec( "cmd.exe /c set" );
        }
      else {
        // our last hope, we assume Unix (thanks to H. Ware for the fix)
        p = r.exec( "env" );
        }
      BufferedReader br = new BufferedReader
         ( new InputStreamReader( p.getInputStream() ) );
      String line;
      while( (line = br.readLine()) != null ) {
       int idx = line.indexOf( '=' );
       String key = line.substring( 0, idx );
       String value = line.substring( idx+1 );
       envVars.setProperty( key, value );
       // System.out.println( key + " = " + value );
       }
      return envVars;
      }  public static void main(String args[]) {
       try {
         Properties p = ReadEnv.getEnvVars();
         System.out.println("the current value of TEMP is : " +
            p.getProperty("TEMP"));
         }
       catch (Throwable e) {
         e.printStackTrace();
         }
       }
      }
      

  4.   

    给你提供一个比较完善的,希望你思考一下,呵呵,
    //import java.util.*;
    import java.util.Properties;
    import java.util.Enumeration;
    import java.util.Map;
    import java.util.Set;
    import java.util.Iterator;public class GetSysPropertiesAndEnv
    {
     public static void main(String [] args)
     {
      //获取所有系统属性
       Properties prpt = System.getProperties();
       Enumeration enm = prpt.propertyNames();  //返回系统属性列表中所有键的枚举
       String key = "";
       System.out.println("当前系统属性如下:=========");
       while(enm.hasMoreElements())
      {
       key = (String) enm.nextElement();
       System.out.println(key+":"+System.getProperty(key,"undefined"));
      }  //获取所有环境变量的设置
       Map map = System.getenv();       //返回系统环境变量的字符串映射视图。
       Set  set  = map.keySet();        //返回映射中包含的键的 set 视图
       System.out.println("当前环境变量如下:=========");
       Iterator itr = set.iterator();
       while(itr.hasNext())
      {
       key = (String) itr.next();
       System.out.println(key+":"+map.get(key));
      }
     }
    }