ProgramingTip

정적 초기화 프로그램을 실행하지 않고 Java 클래스 경로에 클래스가 있는지 확인하십시오.

bestdevel 2020. 11. 28. 10:14
반응형

정적 초기화 프로그램을 실행하지 않고 Java 클래스 경로에 클래스가 있는지 확인하십시오.


내가 사용한다면

   try {
      Class.forName("my.package.Foo");
      // it exists on the classpath
   } catch(ClassNotFoundException e) {
      // it does not exist on the classpath
   }

"Foo"의 초기화 초기화 블록이 시작됩니다. 정적 초기화 프로그램을 시작하지 않고 "my.package.Foo"클래스가 클래스가 있는지 확인할 수있는 방법이 있습니까?


forName(String name, boolean initialize, ClassLoader loader)방법을 시도하고 Class매개 변수 initializefalse.

JavaDoc 링크

참고 URL : https://stackoverflow.com/questions/3466568/check-if-class-exists-in-java-classpath-without-running-its-static-initializer

반응형