Source is thought that there is no problem, but NullpointException happens.

private Object createObject(String name)
Object obj = null;
try
Class cls = Class.forName(name);     
obj = cls.newInstance();//<=Error point
catch(Throwable e)
System.err.println(e);
return obj;     
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Above source is method that have class'name and create instance.
I made new class beside existent class.
This method does not create new instance.
Source is thought that there is no problem, but NullpointException happens.
Ask your opinion.

Class.forName( name ) probably can't find the class you are looking for. Do remember that it must be the full path to the class regardless of where the class resides.
For example, if you want a new JFrame you need.
Class cls = Class.forName( "javax.swing.JFrame" ).
See if that helps.
Bryan

Similar Messages

Maybe you are looking for