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...


All times are GMT -5. The time now is 07:03 AM.