public class JWhich { /**
* Prints the absolute pathname of the class file
* containing the specified class name, as prescribed
* by the current classpath.
*
* @param className Name of the class.
*/
public static void which(String className) { if (!className.startsWith("/")) {
className = "/" + className;
}
className = className.replace('.', '/');
className = className + ".class"; java.net.URL classUrl =
new JWhich().getClass().getResource(className); if (classUrl != null) {
System.out.println("\nClass '" + className +
"' found in \n'" + classUrl.getFile() + "'");
} else {
System.out.println("\nClass '" + className +
"' not found in \n'" +
System.getProperty("java.class.path") + "'");
}
} public static void main(String args[]) {
if (args.length > 0) {
JWhich.which(args[0]);
} else {
System.err.println("Usage: java JWhich <classname>");
}
}
}
> java JWhich javax.servlet.http.HttpServletClass 'javax.servlet.http.HttpServlet' found in
'file:/home/mclark/lib/servlet.jar!/javax/servlet/http/HttpServlet.class'
* Prints the absolute pathname of the class file
* containing the specified class name, as prescribed
* by the current classpath.
*
* @param className Name of the class.
*/
public static void which(String className) { if (!className.startsWith("/")) {
className = "/" + className;
}
className = className.replace('.', '/');
className = className + ".class"; java.net.URL classUrl =
new JWhich().getClass().getResource(className); if (classUrl != null) {
System.out.println("\nClass '" + className +
"' found in \n'" + classUrl.getFile() + "'");
} else {
System.out.println("\nClass '" + className +
"' not found in \n'" +
System.getProperty("java.class.path") + "'");
}
} public static void main(String args[]) {
if (args.length > 0) {
JWhich.which(args[0]);
} else {
System.err.println("Usage: java JWhich <classname>");
}
}
}
> java JWhich javax.servlet.http.HttpServletClass 'javax.servlet.http.HttpServlet' found in
'file:/home/mclark/lib/servlet.jar!/javax/servlet/http/HttpServlet.class'
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货