Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
“线程中的异常”;“主要”;java.lang.ClassNotFoundException在Class.forName中_Java - Fatal编程技术网

“线程中的异常”;“主要”;java.lang.ClassNotFoundException在Class.forName中

“线程中的异常”;“主要”;java.lang.ClassNotFoundException在Class.forName中,java,Java,我在这里附上了我的代码。我尝试使用newInstance方法获取对象。它显示了classnotfoundexception您必须在类中包含包名,才能创建一个新的abc类实例,如下所示,您还必须抛出一些异常,我在下面的示例中已经提到过 public class TestCircle { public static void main(String args[]) throws InstantiationException, IllegalAccessException, ClassNot


我在这里附上了我的代码。我尝试使用
newInstance
方法获取对象。它显示了
classnotfoundexception

您必须在类中包含包名,才能创建一个新的abc类实例,如下所示,您还必须抛出一些异常,我在下面的示例中已经提到过

public class TestCircle {

    public static void main(String args[]) throws InstantiationException, IllegalAccessException, ClassNotFoundException{
        Class.forName("yourPackageName.abc").newInstance();

    }
 }

class abc {
    static
          {
            System.out.println("Executed static block");
          } {
            System.out.println("Executed Object");
        }
}
1.2.您需要传递完全限定的类名,例如,
com.TestAbc.abc