Posted By

macbeth76 on 06/18/09


Tagged

classpath


Versions (?)

Java Tips - How to print classpath


 / Published in: Java
 

URL: http://www.java-tips.org/java-se-tips/java.lang/how-to-print-classpath.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. }

Report this snippet  

You need to login to post a comment.