How to print the default java classpath from the command line in windows

36,513

Solution 1

  1. jdk/bin/jps should list all the java process IDs running that system
  2. subsequently invoke jdk/bin/jinfo <pid> to see lot of information... what you require is also there...

Solution 2

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

Share:
36,513

Related videos on Youtube

Barton Chittenden
Author by

Barton Chittenden

Juggler, Bash jockey, Perl scripter, Linuxhead, code janitor.

Updated on September 18, 2022

Comments

  • Barton Chittenden
    Barton Chittenden over 1 year

    I'm doing some trouble-shooting which requires me to know the default classpath under windows. There's java code which will do this (e.g. http://dev-answers.blogspot.com/2006/06/how-do-you-print-java-classpath.html), but I would really like to see something like you would get from perl -V:

    ...
    @INC:
    /etc/perl
    /usr/local/lib/perl/5.10.1
    /usr/local/share/perl/5.10.1
    /usr/lib/perl5
    /usr/share/perl5
    /usr/lib/perl/5.10
    /usr/share/perl/5.10
    /usr/local/lib/site_perl
    

    Does Java have a quick command-line way of doing this?

  • vonbrand
    vonbrand about 11 years
    No more direct way to get the info?!
  • K Adithyan
    K Adithyan about 11 years
    since the requirement is to get the information from command line, I said this. This is the easiest way in command line. if graphical view is ok, there are tools jvisualvm, jconsole, profilers, etc. From code we can get the same information using System.out.println(System.getProperty("java.class.path"));