LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-15-2012, 06:07 PM   #1
0wn3r
LQ Newbie
 
Registered: Sep 2012
Posts: 1

Rep: Reputation: Disabled
Angry 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?
 
Old 09-16-2012, 02:26 AM   #2
rhklinux
Member
 
Registered: Jan 2010
Location: india/pune
Distribution: Arch Fedora20
Posts: 126

Rep: Reputation: 18
post output of java -version
 
Old 09-16-2012, 02:40 AM   #3
414N
Member
 
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 635

Rep: Reputation: 186Reputation: 186
What distro are you using?
 
Old 12-11-2012, 09:12 PM   #4
cpocanada
LQ Newbie
 
Registered: Dec 2012
Posts: 16

Rep: Reputation: Disabled
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)

Last edited by cpocanada; 12-15-2012 at 08:13 PM.
 
Old 12-18-2012, 08:49 PM   #5
cpocanada
LQ Newbie
 
Registered: Dec 2012
Posts: 16

Rep: Reputation: Disabled
help?

Please help...
 
Old 01-26-2013, 04:21 PM   #6
bobhenz
LQ Newbie
 
Registered: Jan 2013
Posts: 1

Rep: Reputation: Disabled
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.
 
Old 01-26-2013, 05:34 PM   #7
Snark1994
Senior Member
 
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Quote:
Originally Posted by cpocanada View Post
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).
 
Old 01-26-2013, 08:06 PM   #8
cpocanada
LQ Newbie
 
Registered: Dec 2012
Posts: 16

Rep: Reputation: Disabled
Quote:
Originally Posted by bobhenz View Post
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.
 
Old 01-26-2013, 08:09 PM   #9
cpocanada
LQ Newbie
 
Registered: Dec 2012
Posts: 16

Rep: Reputation: Disabled
Quote:
Originally Posted by Snark1994 View Post
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.
 
Old 01-26-2013, 08:14 PM   #10
cpocanada
LQ Newbie
 
Registered: Dec 2012
Posts: 16

Rep: Reputation: Disabled
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.
 
Old 01-27-2013, 06:37 AM   #11
Snark1994
Senior Member
 
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Quote:
Originally Posted by cpocanada View Post
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,
 
Old 01-27-2013, 10:21 PM   #12
cpocanada
LQ Newbie
 
Registered: Dec 2012
Posts: 16

Rep: Reputation: Disabled
Quote:
Originally Posted by Snark1994 View Post
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
 
Old 01-28-2013, 03:26 AM   #13
Snark1994
Senior Member
 
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
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,
 
Old 01-28-2013, 09:10 PM   #14
cpocanada
LQ Newbie
 
Registered: Dec 2012
Posts: 16

Rep: Reputation: Disabled
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
 
Old 01-29-2013, 06:43 AM   #15
Snark1994
Senior Member
 
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
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...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to write a daemon Linux service to a Java application which execute a .jar haseit Linux - Newbie 2 10-14-2011 03:10 AM
Gentoo doesn't run a Java (Flash) application but on Ubuntu yes! fbcyborg Gentoo 2 05-05-2010 05:23 AM
KDE jar MIME is application/zip and not application/java-archive in Ubuntu Intrepid? arobinson74 Linux - Software 2 09-18-2009 11:40 AM
How to run JAR from within Java program ?! EAD Programming 1 12-31-2006 07:11 PM
how do i execute a jar (java application) in linux amolgupta Linux - Software 2 07-20-2006 05:55 AM


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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration