In Get location of JAR file 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".
This is my code:
public static void main(String[] args) {
System.out.println(System.getProperty("java.class.path"));
}
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.
For example:
C:\TEMP>set CLASSPATH=C:\TEMP\BackupCompilations\Photos;C:\FreeOCR\tessdata
C:\TEMP>echo %CLASSPATH%
C:\TEMP\BackupCompilations\Photos;C:\FreeOCR\tessdata
C:\TEMP>set CLASSPATH
CLASSPATH=C:\TEMP\BackupCompilations\Photos;C:\FreeOCR\tessdata
C:\TEMP>java -jar C:\Programs\bin\Test_one_prop.jar
C:\Programs\bin\Test_one_prop.jar
I also tried using -cp on the command line.
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?
(Understood that in Eclipse it returns my project's bin folder.)
This is the only use case I'm concerned with: running this program as a runnable jar.
Thanks.