<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.theeggeadventure.com/wikimedia/index.php?action=history&amp;feed=atom&amp;title=Maximum_Classpath_Length</id>
	<title>Maximum Classpath Length - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.theeggeadventure.com/wikimedia/index.php?action=history&amp;feed=atom&amp;title=Maximum_Classpath_Length"/>
	<link rel="alternate" type="text/html" href="https://www.theeggeadventure.com/wikimedia/index.php?title=Maximum_Classpath_Length&amp;action=history"/>
	<updated>2026-05-13T10:33:56Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.0-beta</generator>
	<entry>
		<id>https://www.theeggeadventure.com/wikimedia/index.php?title=Maximum_Classpath_Length&amp;diff=2079&amp;oldid=prev</id>
		<title>Brianegge: New page: In looking at [Ssh argument length], I decided to figure out how many classes I could put on the Java classpath using Solaris.    So, I coded this little bash script which creates tiny one...</title>
		<link rel="alternate" type="text/html" href="https://www.theeggeadventure.com/wikimedia/index.php?title=Maximum_Classpath_Length&amp;diff=2079&amp;oldid=prev"/>
		<updated>2009-03-31T22:04:12Z</updated>

		<summary type="html">&lt;p&gt;New page: In looking at [Ssh argument length], I decided to figure out how many classes I could put on the Java classpath using Solaris.    So, I coded this little bash script which creates tiny one...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;In looking at [Ssh argument length], I decided to figure out how many classes I could put on the Java classpath using Solaris.  &lt;br /&gt;
&lt;br /&gt;
So, I coded this little bash script which creates tiny one class jars, and then attempts to load them.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;geshi lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
TMP=&amp;quot;${HOME}/tmp/cp/&amp;quot;&lt;br /&gt;
mkdir -p $TMP&lt;br /&gt;
cd $TMP&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Checking for maximum classpath length&amp;quot;&lt;br /&gt;
&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; CheckClasspath.java&lt;br /&gt;
public class CheckClasspath {&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    try {&lt;br /&gt;
      Class.forName(args[0]);&lt;br /&gt;
      System.out.println(&amp;quot;Found class &amp;quot; + args[0]);&lt;br /&gt;
    } catch (ClassNotFoundException e) {&lt;br /&gt;
      System.err.println(&amp;quot;Failed to find class &amp;quot; + args[0]);&lt;br /&gt;
      System.exit(1);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
javac CheckClasspath.java&lt;br /&gt;
java -cp . CheckClasspath CheckClasspath || exit 1&lt;br /&gt;
&lt;br /&gt;
CP=&amp;quot;.&amp;quot;&lt;br /&gt;
for i in $(seq 1 100000); do&lt;br /&gt;
  if [ ! -f &amp;quot;C$i.jar&amp;quot; ]; then&lt;br /&gt;
    cat &amp;lt;&amp;lt;EOF &amp;gt; C$i.java&lt;br /&gt;
public class C$i {&lt;br /&gt;
}&lt;br /&gt;
EOF&lt;br /&gt;
    javac C$i.java&lt;br /&gt;
    jar cf C$i.jar C$i.class&lt;br /&gt;
    /bin/rm C$i.java C$i.class&lt;br /&gt;
  fi&lt;br /&gt;
  CP=&amp;quot;$CP:C$i.jar&amp;quot;&lt;br /&gt;
  if [ $(($i%100)) -eq 0 ]; then&lt;br /&gt;
    java -d64 -Xms8g -Xmx8g -cp &amp;quot;$CP&amp;quot; CheckClasspath C$i || exit 1&lt;br /&gt;
  fi&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/geshi&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using a default 1GB 32 bit JVM, I was able to put 8600 jars.  Increasing the memory to 2GB allowed me to about double this and get to 16700.  Then I switched to an 8GB 64-bit JVM.  At 37818 jars my test case would take about five minutes to execute.  I didn&amp;#039;t test how many classes I could load into the JVM, but I suspect quite a few more than I could jars.  At any rate, one doesn&amp;#039;t need to worry about Java truncating the classpath, but rather it&amp;#039;s the usual memory and CPU constrains that put an upper limit on the jars.&lt;br /&gt;
&lt;br /&gt;
[[Category:Java]] [[Category:Solaris]]&lt;/div&gt;</summary>
		<author><name>Brianegge</name></author>
	</entry>
</feed>