Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / August 2006

Tip: Looking for answers? Try searching our database.

opening an eclipse .jar file

Thread view: 
TrevorBoydSmith@gmail.com - 16 Aug 2006 23:35 GMT
I created the tutorial helloworld project that prints text to a
console.  I want to make it into a .jar so that I can double-click and
have it automatically run using the Java Runtime Environment.  So I
used the export command and created a .jar file.  (making sure to: not
compress, export generated class files and resources.)  After those
setting I clicked finish.  And expected the .jar file to double click
and open a console application.  But nothing happened.  I also tried
opening the .jar file in the command line.  (This is on windows.)

How do you get a .jar file to work when you double-click?  (if you know
a good source to read about this please leave a link on it)
Brandon McCombs - 16 Aug 2006 23:53 GMT
> I created the tutorial helloworld project that prints text to a
> console.  I want to make it into a .jar so that I can double-click and
[quoted text clipped - 7 lines]
> How do you get a .jar file to work when you double-click?  (if you know
> a good source to read about this please leave a link on it)

either wrap it into a .bat file and put a java.exe command in the bat
file to execute the jar or the more appropriate way is to associate .jar
files with javaw.exe in your Windows MIME types so that javaw.exe is
executed to run it just like msword.exe runs for .doc files.
Lee Weiner - 17 Aug 2006 00:31 GMT
>I created the tutorial helloworld project that prints text to a
>console.  I want to make it into a .jar so that I can double-click and
[quoted text clipped - 7 lines]
>How do you get a .jar file to work when you double-click?  (if you know
>a good source to read about this please leave a link on it)

In Windows, when you install the JRE, jar files get associated with javaw.exe.
javaw supresses the console screen.  IOW, your program may be running
properly, but you can't see the output.  If you want to double-click console
programs and have them visible, change the Windows file association from
javaw.exe to java.exe.

Lee Weiner
lee AT leeweiner DOT org
Andrew Thompson - 17 Aug 2006 00:40 GMT
> I created the tutorial helloworld project that prints text to a
> console.  I want to make it into a .jar so that I can double-click and
> have it automatically run using the Java Runtime Environment.  So I
> used the export command and created a .jar file.  (making sure to: not
> compress,

The classes and resources in a jar file can be compressed.

Note that there are a variety of forms of Zip compression
some fo which standard Java does not understand
(e.g. WinZip's 'max. compression' settings), but if you
use the Jar tool to do the compression, you can be sure
that Java can inflate the file.

>...export generated class files and resources.)  After those
> setting I clicked finish.  And expected the .jar file to double click
> and open a console application.  But nothing happened.  I also tried
> opening the .jar file in the command line.  (This is on windows.)
>
> How do you get a .jar file to work when you double-click?

Add a manifest file that specifies the 'main' class.

>..(if you know
> a good source to read about this please leave a link on it)

<http://java.sun.com/j2se/1.5.0/docs/guide/jar/jar.html#Main%20Attributes>

HTH

Andrew T.
Thorgull - 17 Aug 2006 06:09 GMT
If you want the quick and easy solution  look at this eclipse plugin :
FatJar ( http://fjep.sourceforge.net/ )

This plugin add a command in the context menu of projet ("build fat
jar" or something like that). this command create a jar file with a
manifest and include all dependencies of your project in the jar. The
plugin has a lot of options but the default one's will be just fine in
your case. (just click next next next ...)

To run a jar by double clicking on it in windows you need to associate
the files *.jar with the command "$JAVA_HOME\bin\javaw.exe" -jar "%1"
%* (replace $JAVA_HOME by the path to your jre)

> I created the tutorial helloworld project that prints text to a
> console.  I want to make it into a .jar so that I can double-click and
[quoted text clipped - 7 lines]
> How do you get a .jar file to work when you double-click?  (if you know
> a good source to read about this please leave a link on it)


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.