<div>Well, your method's working.</div><div><br></div><div>but according to:<a href="http://download.oracle.com/javase/6/docs/api/java/lang/System.html#getProperties()">http://download.oracle.com/javase/6/docs/api/java/lang/System.html#getProperties()</a></div>
<div>"user.dir    User's [b]current working directory[/b]
 " - I'd expect that to point to "properly" current working dir path all the time:/</div><div><br></div><div>Anyway, thanks for your help, </div><div>
If it's not a bug good to know there's a trap like that
<br></div><div><br></div><div>Marcin</div><br><div class="gmail_quote">2011/6/7 Niels Thykier <span dir="ltr"><<a href="mailto:niels@thykier.net">niels@thykier.net</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
On 2011-06-06 12:17, Marcin wrote:<br>
> Package: sun-java6-jre<br>
> Version: 6.25-3<br>
> Severity: important<br>
><br>
> There's probably problem with workig directory [System.getProperty("user.dir")]<br>
> when trying to run *.jar (eg abc_program.jar) by opening via "Sun java 6<br>
> Runtime"<br>
>  (the same with OpenJDK).<br>
><br>
> System.getProperty("user.dir") return user home directory istead current work<br>
> dir.<br>
><br>
> Problem doesn't exist when application is launching via console eg.:<br>
> java -jar abc_program.jar<br>
><br>
><br>
> [...]<br>
<br>
I am fairly certain that is the "intended behaviour" since the workdir<br>
for your desktop is most likely your home dir (and I assumed "Sun java 6<br>
Runtime" refers to a menu or "Open with ...").<br>
<br>
You should be able to reproduce this with the following in the terminal:<br>
<br>
 $ cd ~<br>
 $ java -jar /abs/path/to/abc_program.jar<br>
<br>
In this case "user.dir" should also be your home-dir; if you want to<br>
locate the path to the jar file, then you need something like:<br>
<br>
  this.getClass().getProtectionDomain().getCodeSource().getLocation();<br>
  SomeClass.class.getProtectionDomain().getCodeSource().getLocation();<br>
<br>
(possibly with some null checks in between).<br>
<font color="#888888"><br>
~Niels<br>
<br>
</font></blockquote></div><br>