Java Tips - How to print classpath


/ Published in: Java
Save to your folder(s)



Copy this code and paste it in your HTML
  1. import java.net.URL;
  2. import java.net.URLClassLoader;
  3.  
  4. public class PrintClasspath {
  5. public static void main(String[] args) {
  6.  
  7. //Get the System Classloader
  8. ClassLoader sysClassLoader = ClassLoader.getSystemClassLoader();
  9.  
  10. //Get the URLs
  11. URL[] urls = ((URLClassLoader)sysClassLoader).getURLs();
  12.  
  13. for(int i=0; i< urls.length; i++)
  14. {
  15. System.out.println(urls[i].getFile());
  16. }
  17.  
  18. }
  19. }

URL: http://www.java-tips.org/java-se-tips/java.lang/how-to-print-classpath.html

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.