Executable Jar File Isnt

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
DrPhill
Level 3
Level 3
Posts: 122
Joined: Mon May 28, 2012 6:32 am

Executable Jar File Isnt

Post 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
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Started with Mint 12 ... flirted with Ubuntu at 18.x.
Now back to Mint with XFCE. Loving it, thanks to all who have contributed.

Phill
User avatar
xenopeek
Level 25
Level 25
Posts: 29459
Joined: Wed Jul 06, 2011 3:58 am

Re: Executable Jar File Isnt

Post by xenopeek »

Have you made the file executable? Right-click it in file manager > Properties > Permissions > Allow executing file as program.
Image
DrPhill
Level 3
Level 3
Posts: 122
Joined: Mon May 28, 2012 6:32 am

Re: Executable Jar File Isnt

Post 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.........
Started with Mint 12 ... flirted with Ubuntu at 18.x.
Now back to Mint with XFCE. Loving it, thanks to all who have contributed.

Phill
altair4
Level 20
Level 20
Posts: 11419
Joined: Tue Feb 03, 2009 10:27 am

Re: Executable Jar File Isnt

Post 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.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
DrPhill
Level 3
Level 3
Posts: 122
Joined: Mon May 28, 2012 6:32 am

Re: Executable Jar File Isnt

Post 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.
Started with Mint 12 ... flirted with Ubuntu at 18.x.
Now back to Mint with XFCE. Loving it, thanks to all who have contributed.

Phill
DrPhill
Level 3
Level 3
Posts: 122
Joined: Mon May 28, 2012 6:32 am

Re: Executable Jar File Isnt

Post 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
Started with Mint 12 ... flirted with Ubuntu at 18.x.
Now back to Mint with XFCE. Loving it, thanks to all who have contributed.

Phill
altair4
Level 20
Level 20
Posts: 11419
Joined: Tue Feb 03, 2009 10:27 am

Re: Executable Jar File Isnt

Post 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.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
DrPhill
Level 3
Level 3
Posts: 122
Joined: Mon May 28, 2012 6:32 am

Re: Executable Jar File Isnt

Post 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.
Started with Mint 12 ... flirted with Ubuntu at 18.x.
Now back to Mint with XFCE. Loving it, thanks to all who have contributed.

Phill
DrPhill
Level 3
Level 3
Posts: 122
Joined: Mon May 28, 2012 6:32 am

Re: Executable Jar File Isnt

Post 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.
Started with Mint 12 ... flirted with Ubuntu at 18.x.
Now back to Mint with XFCE. Loving it, thanks to all who have contributed.

Phill
Locked

Return to “Software & Applications”