raseone
Posts: 15
Joined: Mon Oct 13, 2014 1:06 am

.jar files opening with xArchiver rather than running JRE.

Sun Mar 04, 2018 7:09 pm

Hello. I posted a similar question in a less appropriate section of the forum so I'll try again here.

I have a simple, novice question. Why to my executable .jar files open an xArchiver file browser window when I double click them? Shouldn't these files just run when double-clicked? I understand that xArchiver is looking into the .jar package as it should but I'm confused how this became the default behavior.

The .jar files in question run when double-clicked on mac & windows systems & ran when double-clicked on an earlier incarnation of my Raspbian system. I can run them through the terminal and I can run them via .desktop shortcut as well as via a shell script but I get no option to choose the JRE/JDK as default for opening.jar files. in fact I don't see it at all though it is definitely installed & updated...

Been looking into this for a while now with no real answer in sight.

User avatar
topguy
Posts: 5566
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: .jar files opening with xArchiver rather than running JRE.

Sun Mar 04, 2018 10:30 pm

Its the "filebrowser" that decides what happens when you click on the icon of the file or its name. What is different from Mac and Windows is that there is no default "filebrowser" as part of Linux or X-windows or even part of LXDE desktop. You can install and use whichever you like.

This is as rather old blog on the subject but it might shed some light on why behavior changes.
https://lkubaski.wordpress.com/2012/10/ ... d-pcmanfm/

I dont remember if PCManFM isthe standard filebrowser in Raspbian Streth actually, I use the desktop so seldom.

User avatar
jostle
Posts: 16
Joined: Tue Mar 06, 2018 6:26 am

Re: .jar files opening with xArchiver rather than running JRE.

Mon Mar 12, 2018 8:37 am

You need to tell the file browser to associate the '.jar' file type with the 'java -jar' command.
You can do that in the pcmanfm with the following steps

1. Right click on a '.jar' file and select the 'Open With ...' option.
2. In the switch to the 'Custom Command Line' tab in the 'Choose Application' dialog.
3. In the 'Command line to execute' field enter

Code: Select all

java -jar %f
4. Enter a suitable name in the 'Application name...' field. (I called mine 'Jar Opener')
5. Enable the 'Set selected application as default for this file type'
6. Click 'OK'

That's it!
Double click on any '.jar' file should now run the program.

If you are interested in what goes on in the background when you go through this process, have a look at the two new files that have been created
~/.config/mimeapps.list
and
~/.local/share/applications/userapp-java\ -jar-<something>.desktop

You can also get all the details of the desktop menu specification at
https://freedesktop.org/wiki/Specifications/menu-spec/


Hope that helps,
Have Fun ...


Return to “Java”