<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions and answers in java.classpath</title>
<link>https://ask.clojure.org/index.php/qa/contrib-libs/java-classpath</link>
<description></description>
<item>
<title>Answered: Should java.classpath combine classpath sources?</title>
<link>https://ask.clojure.org/index.php/8599/should-java-classpath-combine-classpath-sources?show=8600#a8600</link>
<description>&lt;p&gt;To expand on this slightly, the primary reason enumerating the classpath isn't straightforward is that Java has never defined a supported way to do it.&lt;/p&gt;
&lt;p&gt;The system classloader, which generally loads the dependencies found on the &lt;code&gt;java.class.path&lt;/code&gt; system property, is only guaranteed to be of type &lt;code&gt;ClassLoader&lt;/code&gt;, which is not enumerable.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Until Java 9, it was possible to enumerate the system classloader by relying on an implementation detail: this reliably returned a &lt;code&gt;URLClassLoader&lt;/code&gt;, which has a &lt;code&gt;getURLs&lt;/code&gt; method. This was undocumented behavior, however.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Beginning with Java 9, the system classloader implementation was changed to an internal class that is not enumerable.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Using the &lt;code&gt;java.class.path&lt;/code&gt; system property directly assumes certain runtime behavior, rather than inspecting the result of actual behavior. This assumption holds in many cases, but fails in others.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The ideal solution would be a way to enumerate resources loaded by the system (and possibly platform) classloader that works on Java 9+, so that the entire classpath hierarchy is enumerable.&lt;/p&gt;
&lt;p&gt;Absent this, relying on the &lt;code&gt;java.class.path&lt;/code&gt; property is likely necessary for Java 9+. If doing so, a next-best solution should accommodate at least two particular cases: &lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The application may be running in a container, and &lt;/li&gt;
&lt;li&gt;Dynamic classloaders may add resources at runtime.&lt;/li&gt;
&lt;/ol&gt;
</description>
<category>java.classpath</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/8599/should-java-classpath-combine-classpath-sources?show=8600#a8600</guid>
<pubDate>Sun, 15 Sep 2019 04:40:35 +0000</pubDate>
</item>
<item>
<title>Answered: classpath &quot;empty&quot; when classpath 0.2.2 used with clojure maven plugin 1.3.20+</title>
<link>https://ask.clojure.org/index.php/714/classpath-empty-when-classpath-used-with-clojure-maven-plugin?show=715#a715</link>
<description>Reference: &lt;a href=&quot;https://clojure.atlassian.net/browse/CLASSPATH-6&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;https://clojure.atlassian.net/browse/CLASSPATH-6&lt;/a&gt; (reported by alex+import)</description>
<category>java.classpath</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/714/classpath-empty-when-classpath-used-with-clojure-maven-plugin?show=715#a715</guid>
<pubDate>Wed, 26 Jun 2019 12:00:00 +0000</pubDate>
</item>
</channel>
</rss>