Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

checking whether a package is existent or not

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

like image 978
abson Avatar asked Mar 30 '10 18:03

abson


1 Answers

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");
}
like image 83
Kylar Avatar answered Sep 20 '22 07:09

Kylar