public final class JWhich
extends java.lang.Object
JWhich
is a utility that takes a Java class name and displays the absolute pathname of
the class file that would be loaded first by the class loader, as prescribed by the class path.
JWhich
also validates the class path and reports any non-existent or invalid class
path entries.
Usage is similar to the UNIX which
command.
Example uses:
To find the absolute pathname ofMyClass.class
not in a package:java JWhich MyClassTo find the absolute pathname ofMyClass.class
in themy.package
package:java JWhich my.package.MyClass
Modifier and Type | Method and Description |
---|---|
protected static java.lang.String |
asResourceName(java.lang.String resource) |
static java.net.URL |
findClass(java.lang.String className)
Returns the URL of the resource denoted by the specified class name, as prescribed by the class
path.
|
protected static java.lang.String |
getClasspath()
Return the classpath.
|
static void |
main(java.lang.String[] args) |
static void |
printClasspath()
Print the classpath to System.out.
|
static void |
setClasspath(java.lang.String classpath)
Set the classpath to the given string.
|
static void |
validate()
Validates the class path and reports any non-existent or invalid class path entries.
|
static void |
which(java.lang.String className)
Prints the absolute pathname of the class file containing the specified class name, as
prescribed by the class path.
|
public static void which(java.lang.String className)
className
- name of the classpublic static java.net.URL findClass(java.lang.String className)
className
- name of the classprotected static java.lang.String asResourceName(java.lang.String resource)
public static void validate()
Valid class path entries include directories, .zip
files, and .jar
files.
public static void printClasspath()
public static void setClasspath(java.lang.String classpath)
classpath
- the new classpathprotected static java.lang.String getClasspath()
public static void main(java.lang.String[] args)