how to create .exe file in java?

A

ashwinijain

I have develpoed billing software with 10 classes.
Now I want to create .exe of this project.
so, help me in creating .exe of my project..
 
F

Flo 'Irian' Schaetz

And thus spoke ashwinijain...
I have develpoed billing software with 10 classes.
Now I want to create .exe of this project.
so, help me in creating .exe of my project..

In many cases, this question only shows that you want to do something
you normaly shouldn't do. But of course, there can be good reasons for
that. The question is: Do you want to...

a) Simply make it easier to "execute" your software, so that you
customer doesn't need to type a long text in the command line?

b) Allow your program to be started without having Java installed?

c) Something else?

In case of a), you should read more about the concept of executable .jar
files or write a batch file. In case of b): Forget it, simply add a Java
Runtime Environment to your project. If c): Tell us, why you want to do
that?

Btw: (If I got it right) JBuilder has a feature to make a .exe "wrapper"
for your program, but this is imho nonsense, it justs makes ther file
bigger. You still need an installed Java - and if you have an installed
Java, you can easily execute the .jar itself...

Flo
 
A

ashwinijain

I want to create executable file for first reason
a) Simply make it easier to "execute" your software, so that you
customer doesn't need to type a long text in the command line?
I just want one logo on my desktop so when user double click it, my
software should start running.
 
A

Andrew Thompson

ashwinijain said:
I want to create executable file for first reason
a) Simply make it easier to "execute" your software, so that you
customer doesn't need to type a long text in the command line?
I just want one logo on my desktop so when user double click it, my
software should start running.

Web-start. Works on Win/Mac/Linux/Unix, and can
offer the user a desktop icon (&/or menu item).

Other points in it's favor.
- Auto updating
- Supported by Sun
- Ensures correct JRE versioning

Andrew T.
 
F

Flo 'Irian' Schaetz

And thus spoke Andrew Thompson...
Web-start. Works on Win/Mac/Linux/Unix, and can
offer the user a desktop icon (&/or menu item).

Isn't that a little bit "to much"? Wouldn't be a simply executable .jar
and a suitable link with the correct item on the desktop be enough?

Flo
 
T

Thomas Kellerer

ashwinijain wrote on 01.01.2007 13:08:
I want to create executable file for first reason
a) Simply make it easier to "execute" your software, so that you
customer doesn't need to type a long text in the command line?
I just want one logo on my desktop so when user double click it, my
software should start running.
http://launch4j.sourceforge.net/
 
A

Andrew Thompson

Flo said:
And thus spoke Andrew Thompson...


Isn't that a little bit "to much"?

What? The menu item going too far for you?
...Wouldn't be a simply executable .jar
and a suitable link with the correct item on the desktop be enough?

For the end user? Sure.

'Too much' effort?

With web-start, the end-user clicks a link,
the desktop icon gets created (if they say
'OK' when asked). Could not be easier.

Andrew T.
 
J

Jhair Tocancipa Triana

ashwinijain said:
I want to create executable file for first reason
a) Simply make it easier to "execute" your software, so that you
customer doesn't need to type a long text in the command line?

You can write a script which launches your application (launches it
with the java tool).

Are you saying you want to build an executable not for performance
reasons but to avoid a user to write a "long text" in the command
line? That doesn't make sense to me.
 
K

Knute Johnson

Flo said:
In case of b): Forget it, simply add a Java
Runtime Environment to your project.

Florian:

Do you know how to actually do that? Distribute your application with a
runtime environment that you don't have to install?
 
A

Andrew Thompson

Or.. try it yourself. Here linked is a launch file for
a space simulator (imaginitively titled WotsItsName
while I haggle with the author over the title).

It is sandboxed, and around 150 Kb.

<http://www.1point1c.org/spacesim/sim/app.html#download>

Besides desktop shortcut & menu item, it prompts
for file types/associations (for very obscure file types).

Andrew T.
 
S

Stefan Schmiedl

Florian:

Do you know how to actually do that? Distribute your application with a
runtime environment that you don't have to install?

Assuming your application is packaged in an executable jar file

app.jar

you can just copy over your jre folder so that you have

app.jar
jre_1.x.y_z

Now you need to make sure that your jar is run with the local jre,
so you could do something like

SET JAVA_HOME=jre_1.x.y_z
%JAVA_HOME%\bin\javaw.exe -jar app.jar

and you're done:

app.jar
jre_1.x.y_z
start.bat

As an additional gimmick, pick your favorite win32-exe-generating
tool and emulate the batch commands with it. You might end up with
a 10 kB starter, a 1 MB jar, and 40 MB jre to distribute.

s.
 
K

Knute Johnson

Stefan said:
Assuming your application is packaged in an executable jar file

app.jar

you can just copy over your jre folder so that you have

app.jar
jre_1.x.y_z

Now the users other java stuff doesn't work correctly.
Now you need to make sure that your jar is run with the local jre,
so you could do something like

SET JAVA_HOME=jre_1.x.y_z
%JAVA_HOME%\bin\javaw.exe -jar app.jar

and you're done:

app.jar
jre_1.x.y_z
start.bat

As an additional gimmick, pick your favorite win32-exe-generating
tool and emulate the batch commands with it. You might end up with
a 10 kB starter, a 1 MB jar, and 40 MB jre to distribute.

s.

It would be really nice to be able to hand somebody a CD with your app
and a JRE, have them stick it in their computer and get it to work. As
good as Sun has been about making minimal changes, each JRE has issues
with the others. I have to install updates and new software for clients
at multiple sites. To be able to just copy files and run the program
would solve my biggest operational problems. My software needs JAF,
Java Mail and Java Comm APIs as well. To be able to distribute a ready
to go system instead of installing all of the pieces and parts would be
really nice.
 
T

Thomas Kellerer

Knute Johnson wrote on 01.01.2007 20:01:
It would be really nice to be able to hand somebody a CD with your app
and a JRE, have them stick it in their computer and get it to work. As
good as Sun has been about making minimal changes, each JRE has issues
with the others. I have to install updates and new software for clients
at multiple sites. To be able to just copy files and run the program
would solve my biggest operational problems. My software needs JAF,
Java Mail and Java Comm APIs as well. To be able to distribute a ready
to go system instead of installing all of the pieces and parts would be
really nice.
Have a look at the link I posted:

http://launch4j.sourceforge.net/
 
S

Stefan Schmiedl

Now the users other java stuff doesn't work correctly.

It will work just as it did before. I've done no installation with
global effects, I've just copied a folder. The java.exe in there
will not be used unless you explicitly call it.
It would be really nice to be able to hand somebody a CD with your app
and a JRE, have them stick it in their computer and get it to work.

I did it with an USB stick, but it was just that: stick, click, run (from
stick). If I didn't have to save some data, a CD would have worked just
as well.
My software needs JAF,
Java Mail and Java Comm APIs as well. To be able to distribute a ready
to go system instead of installing all of the pieces and parts would be
really nice.

I don't know if those things would require a more elaborate procedure,
but assuming that redistributing them is legally ok, it's probably just
a matter of placing them where your runtime can find them. Having not done
this, I could be wrong, however.

s.
 
T

Thomas Kellerer

It will work just as it did before. I've done no installation with
global effects, I've just copied a folder. The java.exe in there
will not be used unless you explicitly call it.

Depends on how you changed the variable JAVA_HOME. If you set it in the
batch file, it will only affect the process started by the batch file.
To be sure to avoid side-effects, you should use setlocal inside the
batch file, so the SET will only have an effect during the runtime of
the batch file. This would be important if the user started your batch
file from within an already open command shell. Without setlocal, any
process started from within that shell but after your batch file ran,
will inherit the new setting for JAVA_HOME

Thomas
 
S

Stefan Schmiedl

Depends on how you changed the variable JAVA_HOME. If you set it in the
batch file, it will only affect the process started by the batch file.
To be sure to avoid side-effects, you should use setlocal inside the
batch file, so the SET will only have an effect during the runtime of
the batch file. This would be important if the user started your batch
file from within an already open command shell. Without setlocal, any
process started from within that shell but after your batch file ran,
will inherit the new setting for JAVA_HOME

You're right there ... I knew there was another reason for using
minuscule exe wrappers instead of batch files.

s.
 

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

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top