title: Why does the java.class.path property always return the location of the jar?
body: <p>In <a href="https://stackoverflow.com/questions/15359702/get-location-of-jar-file">Get location of JAR file</a> it was said that "This works [to get the location of a runnable jar file] only so long as you classpath contains just one entry".</p>
  
  <p>This is my code:</p>
  
  <pre><code>   public static void main(String[] args) {
         System.out.println(System.getProperty("java.class.path"));
     }
  </code></pre>
  
  <p>I create a runnable jar (using Eclipse Export), and when I run it, regardless of what I set CLASSPATH to, I only get the path of the runnable jar.</p>
  
  <p>For example:</p>
  
  <pre><code>C:\TEMP&gt;set CLASSPATH=C:\TEMP\BackupCompilations\Photos;C:\FreeOCR\tessdata
  
  C:\TEMP&gt;echo %CLASSPATH%
  C:\TEMP\BackupCompilations\Photos;C:\FreeOCR\tessdata
  
  C:\TEMP&gt;set CLASSPATH
  CLASSPATH=C:\TEMP\BackupCompilations\Photos;C:\FreeOCR\tessdata
  
  C:\TEMP&gt;java -jar C:\Programs\bin\Test_one_prop.jar
  C:\Programs\bin\Test_one_prop.jar
  </code></pre>
  
  <p>I also tried using -cp on the command line.</p>
  
  <p>Can some one come up with a counter-example where this returns something more/other than the location of the jar file I'm running?</p>
  
  <p>(Understood that in Eclipse it returns my project's bin folder.)</p>
  
  <p>This is the only use case I'm concerned with: running this program as a runnable jar.</p>
  
  <p>Thanks.</p>