ExamInterface exam = (ExamInterface)Class.forName("my.dynamic.ExamObject").newInstance();

解决方案 »

  1.   

    ExamInterface ei = (ExamInterface )ExamInterface.class.getClassLoader().loadClass("my.dynamic.ExamObject").newInstance();
      

  2.   

    newInstance();
    还有什么isInstance();
    是干什么用的啊,见倒是常见就是不知道干吗用的????
    问个额外的问题
    怎么得到环境变量啊????
      

  3.   

    newInstance();-->创建一个实例
    还有什么isInstance();-->是否已经创建实例了
    应该是得到一些系统的信息吧:System.getPropertys()
      

  4.   

    public Properties getEnv() throws Exception
     {
          Properties prop=new Properties();
          String OS = System.getProperty("os.name").toLowerCase();
       Process p=null;
       if(OS.indexOf("windows")>-1)
       {
        p=Runtime.getRuntime().exec("cmd /c set");  //其它的操作系统可以自行处理, 我这里是win2k
       }  
       BufferedReader br=new BufferedReader(new InputStreamReader(p.getInputStream()));
       String line;
       while((line=br.readLine())!=null)
       {
        int i=line.indexOf("=");
        if(i>-1)
        {
         String key=line.substring(0,i);
         String value=line.substring(i+1);
         prop.setProperty(key,value);
        }    
       }
       return prop; 
     }