LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Making Java A Default Application To Run .Jar's (Ubuntu 12.04) (https://www.linuxquestions.org/questions/linux-newbie-8/making-java-a-default-application-to-run-jars-ubuntu-12-04-a-4175427439/)

0wn3r 09-15-2012 06:07 PM

Making Java A Default Application To Run .Jar's (Ubuntu 12.04)
 
Well this is really bothering me, I installed JDK1.7.0_07 but it wont allow me to set it as the default to open jar files. I can run the file but I have to select "Java Runtime Enviroment" every time. Is there any way I could add Java 7u7 to the list of applications to use with JAR files?

rhklinux 09-16-2012 02:26 AM

post output of java -version

414N 09-16-2012 02:40 AM

What distro are you using?

cpocanada 12-11-2012 09:12 PM

open .jar with java runtime by default - help requested
 
Hi, I have the same problem. I have Linux Mint 14 64 bit, Cinnamon. When I right-click on the file and go to open with, from the drop down, I have in the list: Java Runtime, Java Web Start, and OpenJDK Java 7 Runtime. The ones that will run it are: Java Runtime and OpenJDK Java 7 Runtime. However, when I go to properties > open with > show other applications, neither of these are listed. How can I change this? Note that I installed Java from the instructions on this page [w**.duinsoft.nl/packages.php?t=en] (under repository) and java works great. output of java -version:

java version "1.7.0_09"
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode)

cpocanada 12-18-2012 08:49 PM

help?
 
Please help...

bobhenz 01-26-2013 04:21 PM

I don't know if this fixes all .jar files, but if you right click on the .jar of interest, select properties, select OpenJDK Java 7 Runtime (or whatever you want the default to be) and then click the "Set as Default button", that worked for me.

Snark1994 01-26-2013 05:34 PM

Quote:

Originally Posted by cpocanada (Post 4852405)
Please help...

Don't bump threads like this.

It's possible that running

Code:

xdg-mime default java application/java-archive
will sort the issue out (depending on your distro).

cpocanada 01-26-2013 08:06 PM

Quote:

Originally Posted by bobhenz (Post 4878191)
I don't know if this fixes all .jar files, but if you right click on the .jar of interest, select properties, select OpenJDK Java 7 Runtime (or whatever you want the default to be) and then click the "Set as Default button", that worked for me.

Java Runtime is not in the "open with" list. After clicking on Show other applications, it is not on the list either.

cpocanada 01-26-2013 08:09 PM

Quote:

Originally Posted by Snark1994 (Post 4878215)
Don't bump threads like this.

It's possible that running

Code:

xdg-mime default java application/java-archive
will sort the issue out (depending on your distro).



I get:
xdg-mime: malformed argument 'java', expected *.desktop
Try 'xdg-mime --help' for more information.


Linux Mint 14 64 bit, Cinnamon by the way.

cpocanada 01-26-2013 08:14 PM

workaround
 
I have a workaround that gacanepa posted on another thread that I'm satisfied with.

http://www.linuxquestions.org/questi...9/#post4853860


create launcher on desktop and put command in: java -jar /home/---path---/file-to-run.jar

Thanks though.

Snark1994 01-27-2013 06:37 AM

Quote:

Originally Posted by cpocanada (Post 4878244)
I get:
xdg-mime: malformed argument 'java', expected *.desktop
Try 'xdg-mime --help' for more information.


Linux Mint 14 64 bit, Cinnamon by the way.

Oh, yeah, sorry, you'll have to create a java.desktop file (in .local/share/applications) based on one of the files in /usr/share/applications/ and link to that instead.

But glad you got it sorted. Can you mark the thread as SOLVED using the link at the top of the page, please.

Regards,

cpocanada 01-27-2013 10:21 PM

Quote:

Originally Posted by Snark1994 (Post 4878400)
Oh, yeah, sorry, you'll have to create a java.desktop file (in .local/share/applications) based on one of the files in /usr/share/applications/ and link to that instead.

But glad you got it sorted. Can you mark the thread as SOLVED using the link at the top of the page, please.

Regards,


Hi Snark1994, and thanks for your help. I don't consider it solved since I have a workaround (something that works even though it's not exactly what I was looking for). Now that you've brought up information about running the command xdg-mime, now I'm interested in making that work. I tried copying the desktop file into the directory that you mentioned and I got the same thing back in terminal as before, xdg-mime: malformed argument 'java', expected *.desktop

Snark1994 01-28-2013 03:26 AM

Okay, you'll need to edit the file (so that it runs java, rather than whatever .desktop file you copied there). But like I said in my last post, the issue with the command is that you need to type:

Code:

xdg-mime default .local/share/applications/java.desktop application/java-archive
(i.e. give the path to the actual java.desktop file)

Regards,

cpocanada 01-28-2013 09:10 PM

I don't know how to proceed. I installed Java from the instructions on this page [www.duinsoft.nl/packages.php?t=en] (under repository) , so maybe my situation is not typical. I did not edit any .desktop file. I put the following into terminal:

xdg-mime default .local/share/applications/update-sun-jre-java.desktop application/java-archive

and got no response. No error, no success message. From the /usr/share/applications folder, all related to java are:

update-sun-jre-controlpanel.desktop
update-sun-jre-java.desktop
update-sun-jre-javaws.desktop
update-sun-jre-policytool.desktop

When I try to change the default program to launch a .jar file (right-click on .jar file, properties, open with), Java Runtime is not on the list (I would like it to be on the list). It is available via right-click on .jar file, open with. As noted in my post below:

http://www.linuxquestions.org/questi...9/#post4853344

The following shows the contents of the update-sun-jre-java.desktop file in case you're wondering.

[Desktop Entry]
Encoding=UTF-8
Name=Java Runtime
Comment=Java Runtime
Exec=/opt/java/64/jre1.7.0_11/bin/java -jar
Terminal=false
Type=Application
Icon=sun-java
MimeType=application/x-java-archive;application/java-archive;application/x-jar;
NoDisplay=true

Snark1994 01-29-2013 06:43 AM

I wouldn't expect there to be a response, and the .desktop file looks fine. If you run "xdg-open foo.jar" it should hopefully open it with java and if you double click on a .jar file I would expect the same to happen. If not, then Ubuntu must use a different method (certainly programmes like Firefox respect the xdg defaults), so more research would be needed...

cpocanada 01-30-2013 09:58 PM

After putting the following into terminal,
xdg-mime default .local/share/applications/update-sun-jre-java.desktop application/java-archive
Nothing has changed.

But that's okay, it's not a big deal, if I don't find a way to change the default to open with Java Runtime, no problem.

When I double-click the file or use xdg-open file-in-question.jar or right-click > open with java web start: java 7 in some form starts up and then reports "Unable to launch application". However when I right click on the .jar file, click open with > java runtime, then in opens fine.

I don't want to mark it as solved, because my original question isn't solved. Is it important to close this thread? I thought that since I have a common distro and that my questions could help others, I would ask for help. Thanks again for your patience!

Snark1994 01-31-2013 03:11 AM

Quote:

Originally Posted by cpocanada (Post 4881058)
I don't want to mark it as solved, because my original question isn't solved. Is it important to close this thread? I thought that since I have a common distro and that my questions could help others, I would ask for help. Thanks again for your patience!

Actually, you can't mark it as SOLVED because it's not your thread. But never mind, hopefully if we find a solution, then it will benefit the OP too.


When you go Properties > Open With... is there an option to "Browse for more" or "Browse for executable" or something similar? It may only appear when you click on "Show Other Applications". If so, then just find java and select it. If not, then could we maybe have a screenshot? I feel there must be a way of doing what you want to do...

cpocanada 01-31-2013 06:44 AM

3 Attachment(s)
There is an option "show other applications" but can't browse, it only gives a list of more programs, and Java Runtime isn't on the list. Java WebStart will not open the .jar file and reports "Unable to launch application". Whereas [right-click on file > open with Java Runtime] runs .jar file perfectly.

cpocanada 01-31-2013 06:45 AM

1 Attachment(s)
another screenshot. reached my maximum of 3 on last post.

Snark1994 01-31-2013 06:52 AM

Hm... And that "Add" button is greyed out no matter where/what you click? Perhaps we need to find someone who actually runs Mint, or maybe I can boot it in a VM...

cpocanada 01-31-2013 07:08 AM

The add button only becomes available after selecting another one in the list other than the current default. No option to browse for program.

cpocanada 01-31-2013 07:31 AM

This is not urgent or really important. Why don't we just wait and see if somebody that's running Mint sees this thread? If not, no big deal...

jkirchner 01-31-2013 07:50 AM

Quote:

Originally Posted by cpocanada (Post 4881321)
This is not urgent or really important. Why don't we just wait and see if somebody that's running Mint sees this thread? If not, no big deal...

The thread's title indicates Ubuntu 12.04 so it may not grab a Mint user's attention. Have you tried posting this in the Mint forums?

Snark1994 02-03-2013 04:23 PM

Okay, we got the problem sorted at least in cpocanada's case: the problem was that the correct mimetype is "application/x-java-archive" (I mistakenly said "application/java-archive"). So the fix was to use the following line in .local/share/applications/mimeapps.list:

Quote:

application/x-java-archive=openjdk-7-java.desktop
@0wn3r: If this also fixes your problem, then please mark this thread as SOLVED using the link at the top of the page.

Regards,


All times are GMT -5. The time now is 05:11 PM.