Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-10-2009, 04:53 AM
Member
 
Join Date: Sep 2009
Posts: 14
Rep Power: 0
StokedOnMe is on a distinguished road
Default Double-clicking .jar files?
Hey guys, I've been programming for a while, but I never made executables... just ran it from the compiler. Now, however, I really want to have an icon for one of my programs that would be conveniently located and clickable. So, I made a jar file, both in Eclipse and BlueJ. When I run this file in command line, it works fine (with "java -jar ..."). In case of Eclipse, this worked with both "jar" and "Executable jar" options. However, when I double click the icon, nothing happens. First I was getting "can't find main class" error, but that was an easy fix with the manifest file. But now, nothing seems to happen at all. Could this be because the program is supposed to run in the command line or whatever the compiler offers and there is nothing to force the computer to open one of those windows? Please help, this is very frustrating )))
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 11-10-2009, 05:30 AM
Senior Member
 
Join Date: Feb 2009
Posts: 629
Rep Power: 2
pbrockway2 is on a distinguished road
Default
With Windows make sure you are using java.exe and not javaw.exe to run your jar file. The latter does not display a console window.

Alternatively put the command that you know runs the program properly inside a batch file.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 11-10-2009, 05:44 AM
Member
 
Join Date: Sep 2009
Posts: 14
Rep Power: 0
StokedOnMe is on a distinguished road
Default
Ok, so I went to properties of the jar file and made it open with java.exe instead of javaw.exe. However, all that achieved is that now the DOS window flashes for a split second and disappears :/

How would I put the command inside the file?
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 11-10-2009, 06:10 AM
Senior Member
 
Join Date: Feb 2009
Posts: 629
Rep Power: 2
pbrockway2 is on a distinguished road
Default
The following works for me (hw.jar just prints hello world to the console).

Code:
@echo OFF
java -jar g:\hw.jar
pause
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 11-10-2009, 07:51 AM
Member
 
Join Date: Sep 2009
Posts: 14
Rep Power: 0
StokedOnMe is on a distinguished road
Default
Wow! Thanks a lot! That was easy ))) Didn't even need the "pause" line really... for the purposes of this program at least.
Thanks again.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 11-10-2009, 09:09 PM
Senior Member
 
Join Date: Feb 2009
Posts: 629
Rep Power: 2
pbrockway2 is on a distinguished road
Default
You're welcome.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 11-12-2009, 02:37 PM
Member
 
Join Date: Nov 2009
Posts: 71
Rep Power: 0
Mekonom is on a distinguished road
Default
A where mus I write this code?where is batch file in project?
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 11-25-2009, 03:24 PM
Member
 
Join Date: Sep 2009
Posts: 14
Rep Power: 0
StokedOnMe is on a distinguished road
Default
You just create it in Notepad.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Tags
double-click, jar

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Double clicking executables jar files? cruxblack New To Java 6 04-23-2009 03:00 AM
Executing JAR File by double clicking jasmu Advanced Java 11 04-22-2009 01:51 PM
non-static method add(double,double) cannot be referenced from a static context cravi85 Java Announcements 5 03-21-2009 10:32 PM
Double.valueOf() vs Double.parseDouble() greenbean New To Java 10 01-12-2009 09:39 AM
Java3D: Clicking and getting coordinates? seabhcan Advanced Java 0 01-11-2008 03:46 PM


All times are GMT +2. The time now is 03:46 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org