Java: 今のclasspathをJava側で確認する

java側から、現在設定されているclasspathを確認したかったので、
サンプルコードを書いてみた。

自分で調べた限り、一撃で取得できる関数みたいなのはなさそうだった。
System.out.println("classpath = " + prop.getProperty("java.class.path", null));
実行結果:
/home/satoshi/github/sample-codes/java/system_properties% ant exec
Buildfile: /home/satoshi/github/sample-codes/java/system_properties/build.xml

mkdir:
    [mkdir] Created dir: /home/satoshi/github/sample-codes/java/system_properties/build/classes

compile:
    [javac] Compiling 1 source file to /home/satoshi/github/sample-codes/java/system_properties/build/classes

exec:
     [java] Hello, Java.
     [java] classpath = /usr/share/ant/lib/ant-launcher.jar:/usr/share/java/xmlParserAPIs.jar:/usr/share/java/xercesImpl.jar:/usr/share/ant/lib/ant-javamail.jar:/usr/share/ant/lib/ant-antlr.jar:/usr/share/ant/lib/ant-stylebook.jar:/usr/share/ant/lib/ant-apache-bsf.jar:/usr/share/ant/lib/ant-apache-log4j.jar:/usr/share/ant/lib/ant-apache-bcel.jar:/usr/share/ant/lib/ant-apache-resolver.jar:/usr/share/ant/lib/ant-apache-regexp.jar:/usr/share/ant/lib/ant.jar:/usr/share/ant/lib/ant-apache-xalan2.jar:/usr/share/ant/lib/ant-launcher.jar:/usr/share/ant/lib/ant-apache-oro.jar:/usr/share/ant/lib/ant-jsch.jar:/usr/share/ant/lib/ant-jdepend.jar:/usr/share/ant/lib/ant-commons-logging.jar:/usr/share/ant/lib/ant-trax.jar:/usr/share/ant/lib/ant-jmf.jar:/usr/share/ant/lib/ant-swing.jar:/usr/share/ant/lib/ant-commons-net.jar:/usr/share/ant/lib/ant-junit.jar:/usr/share/ant/lib/ant-nodeps.jar:/usr/lib/jvm/java-6-sun-1.6.0.22/lib/tools.jar
     [java] baz

BUILD SUCCESSFUL
Total time: 3 seconds

/home/satoshi/github/sample-codes/java/system_properties% java -version
java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) Client VM (build 17.1-b03, mixed mode, sharing)
サンプル:
https://github.com/tanarky/sample-codes/blob/master/java/system_properties/src/SystemProps.java

環境は、Ubuntu 10.10
sun-java6-jdk
  バージョン: 6.22-0ubuntu1~10.04

参考:
Java Get Class path