Creating a windows executable for a jar file

L

Lionel

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.
 
M

mikeboggs

Lionel said:
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.

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
 
M

mikeboggs

Lionel said:
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.

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
 
L

Lionel

mikeboggs said:
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!

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.
 
K

Knute Johnson

Lionel said:
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.

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.
 
L

Lionel

Knute said:
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.

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.
 
B

Brandon McCombs

Lionel said:
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.

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

Andrew Thompson

Lionel wrote:
....
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.
 
T

Thomas Kellerer

Lionel wrote on 11.09.2006 00:44:
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.

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
 
L

Lionel

Thomas said:
Lionel wrote on 11.09.2006 00:44:

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)

This looks interesting. I'm looking into it.

Lionel.
 
L

Lionel

Andrew said:
Lionel wrote:
...

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

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

Lionel.
 
K

Knute Johnson

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

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.
 
A

Andrew Thompson

Lionel said:
...
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top