Ubuntu

cwd is not correctly set, that creates issue when using java applications

Reported by Silvio Ricardo Cordeiro on 2008-05-25
14
Affects Status Importance Assigned to Milestone
Nautilus
New
Medium
nautilus (Ubuntu)
Low
Ubuntu Desktop Bugs

Bug Description

Binary package hint: nautilus

I open a path through the terminal.
I launch a jar file using "java -jar".
Everything works.

I open a path through nautilus.
I launch a jar file with double-click.
The file's supposed to open with some
"Sun Java 6 Runtime" (I suppose it's /usr/bin/java...?)
The program is launched, but the current path is
my home folder ("/home/my-user/.")!

I mean, this code:
          JOptionPane.showMessageDialog(null,
                  new File(".").getAbsolutePath());
will show the current directory when my program
is launched with "java -jar". But when launched by nautilus
it will always print my home folder (whatever the current folder is)!

Right-click -> Open with -> Open with another application... ->
-> Use a custom command -> (typing) "java -jar"
won't help. It's as if nautilus switched the current
directory specially for launching the JVM,
though I'm not sure it will only do that for
"/usr/bin/java" (but since that's the only
language I know that is launched through a VM...)

And, yes, I know, I'll take a good look at Python
as soon as I get some free time ;)

----------------------------------
Ubuntu version: Hardy
Nautilus package policy: 1:2.22.2-0ubuntu6

description: updated
description: updated
Sebastien Bacher (seb128) wrote :

thank you for your bug report, the description is not clear though, why do you think the directory should be changed, nautilus call the command using the selected file filename or uri, the application should handle that correctly

Changed in nautilus:
assignee: nobody → desktop-bugs
importance: Undecided → Low
status: New → Incomplete

I don't think the directory should be changed.
I think nautilus should call the JVM using the current directory,
but it seems to be calling it using my home (/home/my-user).

When I launch java in the terminal, the JVM thinks the current
directory is the current directory.

When I launch java through nautilus, the JVM thinks the current
directory is /home/my-user, regardless of the current directory.
In this case, launching through nautilus, printing the current directory
will always print "/home/my-user", no matter which directory
my .jar file actually is in.

Sebastien Bacher (seb128) wrote :

could you open the bug on bugzilla.gnome.org since you get the issue and can easily reply to their comments there?

Sebastien Bacher (seb128) wrote :

We are closing this bug report because it lacks the information we need to investigate the problem, as described in the previous comments. Please reopen it if you can give us the missing information, and don't hesitate to submit bug reports in the future. To reopen the bug report you can click on the current status, under the Status column, and change the Status back to 'New'. Thanks again!

Changed in nautilus:
status: Incomplete → Invalid
Kamil Páral (kamil.paral) wrote :

I reopen this bug since I have provided additional information in bug #73401, which is a duplicate of this bug. Please read it.

Easily said, when I have ~/app/app.jar and launch it, currently the nautilus do:
$ java -jar ~/app/app.jar
(cwd is undefined, mostly ~)
and should do:
$ cd ~/app
$ java -jar app.jar # or 'java -jar ~/app/app.jar', this doesn't matter
(cwd set to ~/app)

This is because java applications have NO WAY of determining their run location. It's the limitation of the platform. Therefore if they want to use additional files addressed by relative paths, they must be run with cwd set correctly to program directory. On Windows this issue doesn't exist, clearly their launcher implementation always change cwd appropriately. Ubuntu should do this too.

I'm Java developer, this issue makes me a lot of troubles for linux users.

Changed in nautilus:
status: Invalid → New
Sebastien Bacher (seb128) wrote :
Changed in nautilus:
status: New → Triaged
Changed in nautilus:
status: Unknown → New
Sebastien Bacher (seb128) wrote :

when you open a bug upstream could you also update the launchpad? there was already http://bugzilla.gnome.org/show_bug.cgi?id=535277 sent there

Changed in nautilus:
status: Unknown → New
Tritonio (inshame-gmail) wrote :

Confirming this on Ubuntu Jaunty (9.04)!!! Very annoying bug. My home directory was full of trash and many jar simply did not start when double clicking and I didn't knew why until I run java -jar with the full path from a console. This bug exists for 12 months. :-(

Changed in nautilus:
importance: Unknown → Medium
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.