保存文件名为Property.java
javac Property.java
java Property

解决方案 »

  1.   

    改成这样,把try那段去掉:
    import java.util.*;public class Property {
      public static void main(String[] args) {
        System.out.println(new Date());
        Properties p = System.getProperties();
        p.list(System.out);
        System.out.println("--- Memory Usage:");
        Runtime rt = Runtime.getRuntime();
        System.out.println("Total Memory = "
                           + rt.totalMemory()
                           + " Free Memory = "
                           + rt.freeMemory());
      }
    }
      

  2.   

    正确的:
    import java.util.*;public class Property {
      public static void main(String[] args) {
        System.out.println(new Date());
        Properties p = System.getProperties();
        p.list(System.out);
        System.out.println("--- Memory Usage:");
        Runtime rt = Runtime.getRuntime();
        System.out.println("Total Memory = "
                           + rt.totalMemory()
                           + " Free Memory = "
                           + rt.freeMemory());
                           try {
    Thread.currentThread().sleep(5 * 1000);
    } catch(InterruptedException  e) {}
      }
      
    }
      

  3.   

    import java.util.*;public class Property {
      public static void main(String[] args) {
        System.out.println(new Date());
        Properties p = System.getProperties();
        p.list(System.out);
        System.out.println("--- Memory Usage:");
        Runtime rt = Runtime.getRuntime();
        System.out.println("Total Memory = "
                           + rt.totalMemory()
                           + " Free Memory = "
                           + rt.freeMemory());
      try {
    Thread.currentThread().sleep(5 * 1000);
    } catch(InterruptedException e) {}
    }
    }
    改了一下,好用了,多了个'}',把try放到main里
      

  4.   

    文件解决了,是因为我将程序随便起了一个名字1.java结果编译不通过,改为Property.java就可以了。