java : using URLClassLoader to load a class generated at runtime
<p>I am trying   to play with JavaCompiler interface:   </p>

<pre><code>class A&lt;T extends TrackableObject&gt;{

    }

    public class JavaCompolierDemo {

        /**
         * @param args
         * @throws IOException 
         */
        public static void main(String[] args) throws IOException {
            File sourceFile = new File("c:\\java\\DOModel.java");
            JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
            compiler.run(null, null, null, "-cp", System.getProperties().getProperty("java.class.path") + ";F:\\IndigoSpace\\ejp", sourceFile.getPath());
            System.out.println(new File("c:\\java\\").toURI().toURL());
            URLClassLoader loader = new URLClassLoader(new URL[]{new File("c:\\java\\").toURI().toURL()});
            try {
                loader.loadClass("amarsoft.dbmp.credit.web.model.DOModel");
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
        }

    }
</code></pre>

<p>but when I run above  code a ClassNotFoundException was thrown:</p>

<pre><code>file:/c:/java/
java.lang.ClassNotFoundException: amarsoft.dbmp.credit.web.model.DOModel
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    at amarsoft.rcp.base.util.test.JavaCompolierDemo.main(JavaCompolierDemo.java:31)
</code></pre>

<p>the source code being compiled :</p>

<pre><code>package amarsoft.dbmp.credit.web.model;

import amarsoft.rcp.base.databinding.TrackableObject;
import ejp.annotations.ConcreteTableInheritance;

@ConcreteTableInheritance
public class DOModel extends TrackableObject {
    /**
     * 
     */
    private static final long serialVersionUID = -7066464988987508089L;
    /**
     * 编号
     */
    private String id;
    /**
     * 名称
     */
    private String name;
    /**
     * 模板类型，没有太大意义
     */
    private String type;
    /**
     * 模板参数
     */
    private String args;

    private String updateTable;

    private String updateWhere;

    private String fromClause;

    private String whereClause;

    private String groupClause;

    private String orderClause;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.firePropertyChange("id", this.id, this.id = id);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.firePropertyChange("name", this.name, this.name = name);
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.firePropertyChange("type", this.type, this.type = type);
    }

    public String getArgs() {
        return args;
    }

    public void setArgs(String args) {
        this.firePropertyChange("args", this.args, this.args = args);
    }

    public String getUpdateTable() {
        return updateTable;
    }

    public void setUpdateTable(String updateTable) {
        this.firePropertyChange("updateTable", this.updateTable, this.updateTable = updateTable);
    }

    public String getDoUpdateWhere() {
        return updateWhere;
    }

    public void setDoUpdateWhere(String doUpdateWhere) {
        this.firePropertyChange("updateWhere", this.updateWhere, this.updateWhere = doUpdateWhere);
    }

    public String getFromClause() {
        return fromClause;
    }

    public void setFromClause(String fromClause) {
        this.firePropertyChange("fromClause", this.fromClause, this.fromClause = fromClause);
    }

    public String getWhereClause() {
        return whereClause;
    }

    public void setWhereClause(String whereClause) {
        this.firePropertyChange("whereClause", this.whereClause, this.whereClause = whereClause);
    }

    public String getGroupClause() {
        return groupClause;
    }

    public void setGroupClause(String groupClause) {
        this.firePropertyChange("groupClause", this.groupClause, this.groupClause = groupClause);
    }

    public String getOrderClause() {
        return orderClause;
    }

    public void setOrderClause(String orderClause) {
        this.firePropertyChange("orderClause", this.orderClause, this.orderClause = orderClause);
    }

    @Override
    public String toString() {
        return "DOModel [id=" + id + ", name=" + name + "]";
    }


}
</code></pre>

<p>what's wrong with my code ? the class file was generated, I am  sure of that.
<img src="http://i.stack.imgur.com/IQqTZ.png" alt="enter image description here"></p>
