Page 1 of 1

Executable Jar File Isnt

Posted: Fri Feb 01, 2013 4:54 pm
by DrPhill
OK, this is an odd one. I can execute the jar file in a terminal (java -jar jarfile). I cannot execute the jar file by double-clicking in the file browser. I used to be able to, so I must have muggered something. Anyone with clues as to how to figure this out?

I am running Mint13/Mate. All packages up-to-date. I am producing the jar in eclipse. Machine is pentium i7, 8G ram.

Any help gratefully received

Thanks

Re: Executable Jar File Isnt

Posted: Fri Feb 01, 2013 6:08 pm
by xenopeek
Have you made the file executable? Right-click it in file manager > Properties > Permissions > Allow executing file as program.

Re: Executable Jar File Isnt

Posted: Sat Feb 02, 2013 12:44 pm
by DrPhill
Yep, done that. I have tripped over that one before, so that was the first thing that I tried. That flag also controls executability in the Terminal, so the fact that I can execute in the terminal means that it is set correctly.

Other jars work fine...... maybe it is something incorrect in my Eclipse setup - producing a jar that does not run in the browser.

Is the mechanism the browser uses to execute a jar file different from the way it is done in a terminal? Double click on this works:

Code: Select all

#!/bin/bash

java -jar jarfile.jar
double click on the jar file does not.........

Re: Executable Jar File Isnt

Posted: Sat Feb 02, 2013 1:55 pm
by altair4
Is the mechanism the browser uses to execute a jar file different from the way it is done in a terminal?
Yes it is different.

[1] THe easiest way is to Right Click any *.jar file > Open with other application > Use a custom command > And in the dialog box enter:

Code: Select all

java -jar
From then on a double click should run it.

[2] You could do this system wide if you want although if you are the only user the method above should do it:

Code: Select all

gksu pluma /usr/share/applications/openjdk-7-java.desktop
This is what you should see:
[Desktop Entry]
Name=OpenJDK Java 7 Runtime
Name[fi]=OpenJDK Java 7 - ajonaikainen ympäristö
Comment=OpenJDK Java 7 Runtime
Comment[fi]=OpenJDK Java 7 - ajonaikainen ympäristö
Exec=cautious-launcher %f /usr/bin/java -jar
Terminal=false
Type=Application
Icon=openjdk-7
MimeType=application/x-java-archive;application/java-archive;application/x-jar;
NoDisplay=true
It's "cautious-launcher %f" that's messing you up so just remove it so that the whole file looks like this:
[Desktop Entry]
Name=OpenJDK Java 7 Runtime
Name[fi]=OpenJDK Java 7 - ajonaikainen ympäristö
Comment=OpenJDK Java 7 Runtime
Comment[fi]=OpenJDK Java 7 - ajonaikainen ympäristö
Exec=/usr/bin/java -jar
Terminal=false
Type=Application
Icon=openjdk-7
MimeType=application/x-java-archive;application/java-archive;application/x-jar;
NoDisplay=true
A jar file in and of itself is not an executable entitiy so it really doesn't need to be made executable. "cautious-launcher" is something Ubuntu added - mostly just because they can.

Re: Executable Jar File Isnt

Posted: Sat Feb 02, 2013 2:06 pm
by DrPhill
Hmmmm I do not have java-7, but applied what you said to Java 6. No immediate result. I will try rebooting. Back soon.

Re: Executable Jar File Isnt

Posted: Sat Feb 02, 2013 2:26 pm
by DrPhill
No change.

In fact this is stranger than strange:

- I have one jar file (that I made some time ago) that I can execute by script, in a terminal, or by double click.
- I have a more recently made jar file that I can execute by script or in a terminal, but not by double clicking.
[edit: when I say 'by script' I mean 'by double clicking on a script']

Of course it might be something in the Java rather than in Linux.

Code: Select all

gksu pluma /usr/share/applications/openjdk-6-java.desktop
Gives

Code: Select all

[Desktop Entry]
Name=OpenJDK Java 6 Runtime
Name[fi]=OpenJDK Java 6 - ajonaikainen ympäristö
Comment=OpenJDK Java 6 Runtime
Comment[fi]=OpenJDK Java 6 - ajonaikainen ympäristö
Exec=/usr/bin/java -jar
Terminal=false
Type=Application
Icon=openjdk-6
MimeType=application/x-java-archive;application/java-archive;application/x-jar;
NoDisplay=true

Re: Executable Jar File Isnt

Posted: Sat Feb 02, 2013 2:31 pm
by altair4
I don't know what to tell you. The affect is immediate and does not require a reboot. I just did it again against a Mint13 / Cinnamon / Java6 desktop file in a VBox VM just to make sure and it works as advertised.

If method [1] doesn't work either then it would appear I can't help you, sorry.

Re: Executable Jar File Isnt

Posted: Sat Feb 02, 2013 2:37 pm
by DrPhill
OK, but thanks for trying (I really do appreciate the help, even when the problem is not solved).

I can work-around by using a script, but that feels ugly. Ah well. I suspect that I have accidentally altered a setting. I work on a laptop and the touchpad/mousebuttons are sometimes too sensitive. Up pops a menu and my typing wizzes around the menu altering stuff at lightning speed.

Some things are going a little squiffy with Mint, so I might go for a re-install.

Re: Executable Jar File Isnt

Posted: Sat Feb 02, 2013 5:19 pm
by DrPhill
Just did a clean install of Mint (14/Cinnamon) and the jar file still behaves oddly. That makes it either something in my settings(I used the same home partition) or in the jar file itself.