As shown below:
<span style= "font-size:18px" >
System.out.println ("++++++++++++++++++++++++");
String Path = System.getproperty ("Java.class.path");
String path2 = FreeMarkerWriter.class.getProtectionDomain (). Getcodesource (). GetLocation (). GetPath ();
String path3 = FreeMarkerWriter.class.getProtectionDomain (). Getcodesource (). GetLocation (). GetFile ();
String Path4 = Thread.CurrentThread (). Getcontextclassloader (). GetResource (""). GetPath ();
SYSTEM.OUT.PRINTLN ("Path 1 =" + path);
System.out.println ("Path 2 =" + path2);
System.out.println ("Path 3 =" + path3);
System.out.println ("Path 4 =" + Path4);
System.out.println ("++++++++++++++++++++++++");
</SPAN>
The above Java to get Classpath classpath simple method (recommended) is small to share all the content of everyone, hope to give you a reference, but also hope that we support cloud habitat community.