title: Dynamically class creating by using Java Reflection, java.lang.ClassNotFoundException
body: <p>I want to use reflection in java, I want to do that third class will read the name of the class as String from console. Upon reading the name of the class, it will automatically and dynamically (!) generate that class and call its <code>writeout</code> method. If that class is not read from input, it will not be initialized.</p>
  
  <p>I wrote that codes  but I am always taking to "<code>java.lang.ClassNotFoundException</code>", and I don't know how I can fix it.
  Can anyone help me?</p>
  
  <pre><code>class class3 {  
     public Object dynamicsinif(String className, String fieldName, String value) throws Exception
     {    
        Class cls = Class.forName(className,true,null);    
        Object obj = cls.newInstance();    
        Field fld = cls.getField(fieldName);    
        fld.set(obj, value);    
        return obj;    
    }
  
    public void writeout3()    
    {    
        System.out.println("class3");    
    }    
  }
  
  public class Main {        
      public static void main(String[] args) throws Exception    
      {            
             System.out.println("enter the class name : ");    
         BufferedReader reader= new BufferedReader(new InputStreamReader(System.in));
             String line=reader.readLine();    
             String x="Text1";    
             try{    
                class3 trycls=new class3();    
                Object gelen=trycls.dynamicsinif(line, x, "rubby");    
                Class yeni=(Class)gelen;        
                System.out.println(yeni);                    
            }catch(ClassNotFoundException ex){        
                System.out.print(ex.toString());    
            }    
      }    
  }
  </code></pre>