checking whether a package is existent or not

前端 未结 3 1728
逝去的感伤
逝去的感伤 2020-12-17 17:46

How can i check whether a package like javax.servlet.* exists or not in my installation of java?

3条回答
  •  失恋的感觉
    2020-12-17 18:40

    If you look in the API docs for the installation you have, it will tell you all the installed packages, eg: http://java.sun.com/j2se/1.5.0/docs/api/

    In code, you can do something like this:

    Package foo = Package.getPackage("javax.servlet");
    
    if(null != foo){
      foo.toString();
    }else{
      System.out.println("Doesn't Exist");
    }
    

提交回复
热议问题