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 / September 2006

Tip: Looking for answers? Try searching our database.

Creating a windows executable for a jar file

Thread view: 
Lionel - 10 Sep 2006 23:44 GMT
Hi,

I'm sure someone here knows the answer. All I want is an icon that I can
double click in Windows to launch the jar file. I may need to export
some paths also.

Does anyone know how I can do this? I did create a batch file but it
opens a dos prompt in the background which I don't want.

Thanks

Lionel.
mikeboggs - 11 Sep 2006 00:01 GMT
> Hi,
>
[quoted text clipped - 8 lines]
>
> Lionel.

You can create a .vbs to run it.

set WshShell = createObject("Wscript.shell")
WshShell.run "jar whatever", 0, false

call it "Runjar.vbs" or something...

The 0 in the .run command makes the command prompt invisible.  The
false tells the script not to wait for the program to finish.  Let me
know if this helps or if you have quesitons!

Michael Boggs
mikeboggs - 11 Sep 2006 00:01 GMT
> Hi,
>
[quoted text clipped - 8 lines]
>
> Lionel.

You can create a .vbs to run it.

set WshShell = createObject("Wscript.shell")
WshShell.run "jar whatever", 0, false

the "jar whatever" is of course the command you use to run the jar.
Save the .vbs; call it "Runjar.vbs" or something; then just
double-click it

The 0 in the .run command makes the command prompt invisible.  The
false tells the script not to wait for the program to finish.  Let me
know if this helps or if you have quesitons!

Michael Boggs
Lionel - 11 Sep 2006 00:21 GMT
>> Hi,
>>
[quoted text clipped - 21 lines]
> false tells the script not to wait for the program to finish.  Let me
> know if this helps or if you have quesitons!

Great, I'll give this a go as soon as I can. Will the .vbs extension
show up? Also, how do I go about giving it a custom icon so that it
get's rolled out with that icon when I install?

Thanks

Lionel.
Knute Johnson - 11 Sep 2006 03:57 GMT
>>> Hi,
>>>
[quoted text clipped - 29 lines]
>
> Lionel.

If you can run your jar file with the java.exe program you can make a
shortcut to it and run it by double-clicking on it.  You don't need a
VBS script to start it.

For Java applications in jars you need to specify the class path in the
manifest file.

There is one other possibility, if you are running Windows XP Pro the
file type may not be set correctly in the file types.  Just open My
Computer, Tools Tab, File Types Tab and set the JAR extension to be an
Executable Jar File.

Signature

Knute Johnson
email s/nospam/knute/

Lionel - 11 Sep 2006 04:05 GMT
>>>> Hi,
>>>>
[quoted text clipped - 34 lines]
> shortcut to it and run it by double-clicking on it.  You don't need a
> VBS script to start it.

Yes, I can double click it but there may be other things that I want to
do first, most likely export paths to other libraries, although at this
stage this has miraculously worked. I actually let Netbeans handle
creating the Jar for me, and as it turns out it seems to have been
smarter than I thought.

Can you give the shortcut to the jar an alternative icon? I will check
that myself.

> There is one other possibility, if you are running Windows XP Pro the
> file type may not be set correctly in the file types.  Just open My
> Computer, Tools Tab, File Types Tab and set the JAR extension to be an
> Executable Jar File.

A large reason for using Java is that it's cross-platform. I don't
intend to restrict the application (and the people I work with want it
to run on multiple platforms) to Windows. Personally I rarely use
Windows which is why I had to ask the question.

Thanks for you input.

Lionel.
Brandon McCombs - 11 Sep 2006 04:42 GMT
>>>>> Hi,
>>>>>
[quoted text clipped - 43 lines]
> Can you give the shortcut to the jar an alternative icon? I will check
> that myself.

right click on icon, click on Shortcut tab, there is a button right
there that lets you change the icon.

>> There is one other possibility, if you are running Windows XP Pro the
>> file type may not be set correctly in the file types.  Just open My
[quoted text clipped - 9 lines]
>
> Lionel.
Andrew Thompson - 11 Sep 2006 08:35 GMT
...
> I'm sure someone here knows the answer. All I want is an icon that I can
> double click in Windows to launch the jar file.

JWS can do all this, for windows and 'the other platform'.
(and as mentioned in another post, it allows you to choose
the icon for the desktop shortcut).

Besides that, JWS offers ..
- Java versioning
- Automate program updates
- support by the manufacturer

Andrew T.
Lionel - 11 Sep 2006 22:36 GMT
> ...
>> I'm sure someone here knows the answer. All I want is an icon that I can
[quoted text clipped - 8 lines]
> - Automate program updates
> - support by the manufacturer

My application relies on 6 or more other jars. How can I be sure these
will be exported without writing some custom script?

Lionel.
Knute Johnson - 12 Sep 2006 01:07 GMT
>> ...
>>> I'm sure someone here knows the answer. All I want is an icon that I can
[quoted text clipped - 13 lines]
>
> Lionel.

Exported to where, some foreign country?  Your application jar manifest
must have a Class-path statement in it if the jars are not in the
execution directory.  If they are there is nothing to be done.  This is
really far simpler than everybody is making it out to be.

Signature

Knute Johnson
email s/nospam/knute/

Andrew Thompson - 12 Sep 2006 06:37 GMT
> > ...
> >> I'm sure someone here knows the answer. All I want is an icon that I can
> >> double click in Windows to launch the jar file.
> >
> > JWS can do all this,
..
> My application relies on 6 or more other jars. How can I be sure these
> will be exported without writing some custom script?

Add the Jar's to the 'resources' section of the JNLP
and they will be made accessible to the main Jar via
calls to getResource.

Andrew T.
Thomas Kellerer - 11 Sep 2006 20:55 GMT
Lionel wrote on 11.09.2006 00:44:
> Hi,
>
[quoted text clipped - 4 lines]
> Does anyone know how I can do this? I did create a batch file but it
> opens a dos prompt in the background which I don't want.

Look at Launch4J (http://launch4j.sourceforge.net/) it will create an .exe file
that will start your application. You can have a native splash screen, JDK
version checking and default JVM Parameters. This is *not* a native compiler, it
will simply create an .exe wrapper around your Java program (very much like
javac.exe)

Thomas
Lionel - 11 Sep 2006 22:33 GMT
> Lionel wrote on 11.09.2006 00:44:
>> Hi,
[quoted text clipped - 11 lines]
> native compiler, it will simply create an .exe wrapper around your Java
> program (very much like javac.exe)

This looks interesting. I'm looking into it.

Lionel.


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.