Main difference can be found in what they return:
getClassLoader.getURLs()
Returns the search path of URLs for loading classes and resources. This includes the original list of URLs specified to the constructor, along with any URLs subsequently appended by the addURL() method, see link
System.getProperty("java.class.path")
Path used to find directories and JAR archives containing class files. Elements of the class path are separated by a platform-specific character specified in the path.separator property, see link
Looking at definition, here are the differences:
- First one returns an array of URL whereas second one returns a String.
- First one will also return any URLs appended in runtime using API, second one will not include that.
More or less it depends on what you are trying to achieve when you have to decide which one to pick.
Cheers !!