View the Most Wanted LQ Wiki articles.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 09-27-2003, 11:53 PM   #1
Registered: Jun 2003
Distribution: Redhat
Posts: 245

Rep: Reputation: 30
executable jar in java (cannot double click)


i have successfully made an executable jar in the command line and it works perfectly: java -jar <filename>.jar

the program executes well, but the problem is i always have to open the terminal just to run a jar file.

i cannot double click it on the desktop since it seems to be a compressed file. i changed the file association in gnome, but its still the same, the jar file is understood to be a compressed file.

what seems to be problem here?
Old 09-28-2003, 02:02 AM   #2
Registered: Aug 2003
Location: Planet Earth
Distribution: Linux Mint Debian Edition (LMDE)
Posts: 215

Rep: Reputation: 31
A jar file is the same thing as a zip file... it's just a compressed archive, so it doesn't make sense to "execute" it. Typically what you do is have your main class file -- the one that has "public static void main(String[] args)" in it -- outside the jar file. The rest of your classes are then members of a package, and stored in a jar file in a directory in your $CLASSPATH environment variable.
Old 09-29-2003, 04:43 AM   #3
Registered: Aug 2003
Location: Belgium
Distribution: Debian (server), Kubuntu (desktop)
Posts: 248

Rep: Reputation: 30
You don't have to put your entry point (the class with your main method) outside of your jar file. You should write a script (just a text file) that executes java -jar <filename>.jar and execute the script.
Old 09-29-2003, 09:13 AM   #4
Registered: Jun 2003
Distribution: Redhat
Posts: 245

Original Poster
Rep: Reputation: 30
well, after some clicks and some experimentation, i finally did it...

in my kde, under the control center - components - file associations, i looked for application/x-jar. in the application preference, i added the java executable with a -jar %1 argument.

when i clicked the jar file, it opened the swing program and ran perfectly! :-)


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
mouse: single-click becomes double-click kinzlaw Linux - Hardware 2 08-24-2005 07:55 PM
Fedora Core 1 Associating .jar files with java -jar command pymehta Fedora 0 01-13-2005 05:26 AM
Cannot not run executable jar file after set content type for download antony_csf Programming 1 12-08-2004 12:22 AM
Gnome 2.6.1: Single Click acts like Double Click Der_tolle_Emil Linux - Software 2 09-13-2004 08:59 AM
How can I stop the output screen when double click the jar file antony_csf Programming 3 07-07-2004 06:38 AM

All times are GMT -5. The time now is 08:36 AM.

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