jdk/bin/jpsshould list all the java process IDs running that system- subsequently invoke
jdk/bin/jinfo <pid>to see lot of information... what you require is also there...
jdk/bin/jpsshould list all the java process IDs running that system- subsequently invoke
jdk/bin/jinfo <pid>to see lot of information... what you require is also there...
No need to print the default classpath. In Java, the default classpath is just the current directory:
If -classpath and -cp are not used and CLASSPATH is not set, the user class path consists of the current directory (.).
(documentation of java:)
Note: For completeness' sake: Theree are two other paths where java will look for stuff:
- the bootstrap class path
- the extension directory
The bootstrap class path by default points to parts of the JDK, and you almost never want to mess with it (unless you want to override part of the JDK), so you probably should not worry about it. The extension directories are for extending the JDK; see http://docs.oracle.com/javase/7/docs/technotes/guides/extensions/index.html
How can I print a parseable run time classpath?
debugging - How to debug classpath command line option (-cp) for java executable? - Stack Overflow
java - Listing available classes in current classpath using a command line tool - Stack Overflow
Print the Java Classpath on macOS (Mac OS X) - Stack Overflow
Videos
You can use javap:
$ javap java.lang.String
Compiled from "String.java"
public final class java.lang.String implements java.io.Serializable
[...]
$ javap no.such.Class
Error: class not found: no.such.Class
You can use the -verbose option of the java command and search for the fully qualified name of a specific class.
$ java -verbose -jar MyProgram.jar | grep "java.lang.String" [Loaded java.lang.String from /Library/Java/…/Contents/Home/jre/lib/rt.jar] [Loaded java.lang.StringBuffer from /Library/Java/…/Contents/Home/jre/lib/rt.jar] …
Addendum: I want to check the class availability for an environment.
If you are running from the java command line, either the paths specified in the -classpath option or the CLASSPATH environment variable will be searched. If you are running from a JAR, the manifest's Class-Path attribute, for example, supplants these settings.
If you are trying to find a required JAR that may not be accessible in these ways, you'll have to search the file system. I use a combination of find, jar and grep, typically focussing on paths defined in system properties such as java.endorsed.dirs and java.ext.dirs; several related approaches are shown here.
Unless you explicitly set the CLASSPATH variable in either the current shell or in your login profile (e.g. ~/.bash_profile), then there is no way to show what it is.
If you don't have the CLASSPATH set, then the default value of the class path is ".", meaning that only the current directory is searched. Specifying either the CLASSPATH variable or the -cp command line switch overrides this value.
I'm not sure if $CLASSPATH is available in OSX by default. But, $PATH might help you. This variable has the information about the directories that contain executable commands.