Bug#629398: sun-java6-jre: Incorrect working directory [System.getProperty("user.dir")] when "open with java 6 runtime

Marcin s4ncho at gazeta.pl
Wed Aug 17 10:38:37 UTC 2011


Well, your method's working.

but according to:
http://download.oracle.com/javase/6/docs/api/java/lang/System.html#getProperties()
"user.dir    User's [b]current working directory[/b]  " - I'd expect that to
point to "properly" current working dir path all the time:/

Anyway, thanks for your help,
If it's not a bug good to know there's a trap like that

Marcin

2011/6/7 Niels Thykier <niels at thykier.net>

> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-java-maintainers/attachments/20110817/d6644ddf/attachment-0001.html>


More information about the pkg-java-maintainers mailing list