wood burning stoves*
The moose likes Linux / UNIX and the fly likes Running jar files on linux Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Running jar files on linux" Watch "Running jar files on linux" New topic
Author

Running jar files on linux

Robert Hill
Ranch Hand

Joined: Feb 24, 2006
Posts: 94
What is the secret to running an executable jar file on Linux by clicking on the file? I have java 1.5.x that came with the distro, but is from Sun, is there a missing file?

I can run it via command line.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Depends on the Linux desktop you're using. It's just a matter of adding a file association so that ${JAVA_HOME}/bin/java is used to launch jar files with the proper command-line arguments -- but the details of doing so are distro- and/or desktop- specific.


[Jess in Action][AskingGoodQuestions]
Guy Allard
Ranch Hand

Joined: Nov 24, 2000
Posts: 776
Linux (and any Unix) does not have the concept of "file extension associations" in the way Windows does.

Suggest you write a shell script that executes the correct 'java -jar xxx' command, and click that.

Guy
Arno Reper
Ranch Hand

Joined: Mar 14, 2006
Posts: 286
With Ubuntu...i double-click and it launch the jar...just like in MacOs or Window$
arno


The man who makes no mistakes does not usually make anything<br /> <br />>>> SCJP 5.0 >> SCJD B&S <<< In progress
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Originally posted by Guy Allard:
Linux (and any Unix) does not have the concept of "file extension associations" in the way Windows does.


Ummmmm... Guy, wake up -- it's 2007!

All the popular Linux desktops (KDE, Gnome, etc) offer this feature, and have for some years now. Most distros include a large number of such associations out of the box, including clickable jar files.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16012
    
  19

<nitpick-mode>
Technically, he's right. Linux doesn't.
</nitpick-mode>

But then again, the desktop GUI shell (a/k/a the "desktop") is neither part of Linux, nor its most popular GUI add-on (X Windows). Gnome, KDE, sawfish, etc. are GUI layers independent of the OS or window managers.

But, as Ernest has pointed out, these days most of them do support some sort of mapping between desktop objects and applications.


Customer surveys are for companies who didn't pay proper attention to begin with.
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Originally posted by Tim Holloway:
<nitpick-mode>
Technically, he's right. Linux doesn't.
</nitpick-mode>


<nitpick-mode>
Technically, Windows can only execute .exe, .bat and .com -Files, and uses a similar technique, to associate Files to Programs.
</nitpick-mode>


http://home.arcor.de/hirnstrom/bewerbung
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Originally posted by Tim Holloway:
<nitpick-mode>
Technically, he's right. Linux doesn't.
</nitpick-mode>


Indeed; and to the same extent, it doesn't have the notion of "clicking on files!" To the extent that "clicking on files" has some reality, then file associations do, too
Guy Allard
Ranch Hand

Joined: Nov 24, 2000
Posts: 776
Yes, but the notion of a file being executable is embedded in the OS.

And the various GUI implementations support that. Naturally.

The OS does not support file associations.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Running jar files on linux