LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices



Reply
 
Search this Thread
Old 09-28-2003, 12:53 AM   #1
spyghost
Member
 
Registered: Jun 2003
Distribution: Redhat
Posts: 245

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


hi,

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, 03:02 AM   #2
eric.r.turner
Member
 
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, 05:43 AM   #3
nephilim
Member
 
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, 10:13 AM   #4
spyghost
Member
 
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! :-)
 
  


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


All times are GMT -5. The time now is 04:45 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration