Executable Jar File Isnt

Questions about applications and software
Forum rules
Before you post please read how to get help
DrPhill
Level 2
Level 2
Posts: 98
Joined: Mon May 28, 2012 6:32 am

Executable Jar File Isnt

Postby DrPhill » Fri Feb 01, 2013 4:54 pm

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
Started with Mint 12 ... now on 17.2 suits me just fine.
Thanks to all who have contributed.

Phill

User avatar
xenopeek
Level 23
Level 23
Posts: 19212
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: Executable Jar File Isnt

Postby xenopeek » Fri Feb 01, 2013 6:08 pm

Have you made the file executable? Right-click it in file manager > Properties > Permissions > Allow executing file as program.
Image

DrPhill
Level 2
Level 2
Posts: 98
Joined: Mon May 28, 2012 6:32 am

Re: Executable Jar File Isnt

Postby DrPhill » Sat Feb 02, 2013 12:44 pm

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.........
Started with Mint 12 ... now on 17.2 suits me just fine.
Thanks to all who have contributed.

Phill

altair4
Level 17
Level 17
Posts: 7893
Joined: Tue Feb 03, 2009 10:27 am

Re: Executable Jar File Isnt

Postby altair4 » Sat Feb 02, 2013 1:55 pm

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.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.

DrPhill
Level 2
Level 2
Posts: 98
Joined: Mon May 28, 2012 6:32 am

Re: Executable Jar File Isnt

Postby DrPhill » Sat Feb 02, 2013 2:06 pm

Hmmmm I do not have java-7, but applied what you said to Java 6. No immediate result. I will try rebooting. Back soon.
Started with Mint 12 ... now on 17.2 suits me just fine.
Thanks to all who have contributed.

Phill

DrPhill
Level 2
Level 2
Posts: 98
Joined: Mon May 28, 2012 6:32 am

Re: Executable Jar File Isnt

Postby DrPhill » Sat Feb 02, 2013 2:26 pm

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
Started with Mint 12 ... now on 17.2 suits me just fine.
Thanks to all who have contributed.

Phill

altair4
Level 17
Level 17
Posts: 7893
Joined: Tue Feb 03, 2009 10:27 am

Re: Executable Jar File Isnt

Postby altair4 » Sat Feb 02, 2013 2:31 pm

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.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.

DrPhill
Level 2
Level 2
Posts: 98
Joined: Mon May 28, 2012 6:32 am

Re: Executable Jar File Isnt

Postby DrPhill » Sat Feb 02, 2013 2:37 pm

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.
Started with Mint 12 ... now on 17.2 suits me just fine.
Thanks to all who have contributed.

Phill

DrPhill
Level 2
Level 2
Posts: 98
Joined: Mon May 28, 2012 6:32 am

Re: Executable Jar File Isnt

Postby DrPhill » Sat Feb 02, 2013 5:19 pm

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.
Started with Mint 12 ... now on 17.2 suits me just fine.
Thanks to all who have contributed.

Phill


Return to “Software & Applications”

Who is online

Users browsing this forum: No registered users and 9 guests