Bug#629398: sun-java6-jre: Incorrect working directory [System.getProperty("user.dir")] when "open with java 6 runtime
Niels Thykier
niels at thykier.net
Mon Jun 6 22:00:03 UTC 2011
On 2011-06-06 12:17, Marcin wrote:
> Package: sun-java6-jre
> Version: 6.25-3
> Severity: important
>
> There's probably problem with workig directory [System.getProperty("user.dir")]
> when trying to run *.jar (eg abc_program.jar) by opening via "Sun java 6
> Runtime"
> (the same with OpenJDK).
>
> System.getProperty("user.dir") return user home directory istead current work
> dir.
>
> Problem doesn't exist when application is launching via console eg.:
> java -jar abc_program.jar
>
>
> [...]
I am fairly certain that is the "intended behaviour" since the workdir
for your desktop is most likely your home dir (and I assumed "Sun java 6
Runtime" refers to a menu or "Open with ...").
You should be able to reproduce this with the following in the terminal:
$ cd ~
$ java -jar /abs/path/to/abc_program.jar
In this case "user.dir" should also be your home-dir; if you want to
locate the path to the jar file, then you need something like:
this.getClass().getProtectionDomain().getCodeSource().getLocation();
SomeClass.class.getProtectionDomain().getCodeSource().getLocation();
(possibly with some null checks in between).
~Niels
More information about the pkg-java-maintainers
mailing list