3

First i want to convey is, my Question is Not duplicate to this Question, How can I convert my Java program to an .exe file?.

Since My question, I had wrote a Swing program, in that program, there is a Button called "Generate EXE" , when the Button is clicked i have to generate the EXE of that program, so i need to create EXE via Java Code, i had created EXE using Advance Installer IDE http://www.advancedinstaller.com/user-guide/tutorial-java.html, But now my requirement is i have to generate EXE via Java code not using IDE by manually, my java code has create the EXE.

Thanks

6
  • So you're planning to write a Java-to-executable compiler? Commented May 18, 2011 at 11:44
  • May I ask what would be the point? Commented May 18, 2011 at 11:47
  • @Jan Zyka: yes,My desire is when you click Genearte EXE Button in my program , you have to Program as EXE, so that other user will run that EXE Commented May 18, 2011 at 11:49
  • What about self-executable jar for example? Or a script which executes java with appropriate parameters? or you insist on having exe? I don't see why is exe any better ... Commented May 18, 2011 at 11:53
  • @jan Zyka: I want to create EXE, in the sense an Installer, once you like that Button in my UI, it has to give a SetUp, so that you can take that Setuo file and install and run my current program Commented May 18, 2011 at 11:58

1 Answer 1

2

This is not how to make an exe but since I think these solutions do the same job and I would personally prefer them, will post it anyway:

  • Create executable jar instead of exe
  • generate a script (in your case probably .bat file) which will run the java with appropriate parameters for you

If the exe is absolute requirement, convert the .bat file to exe (google for bat to exe)

Sign up to request clarification or add additional context in comments.

9 Comments

@Jan Zyka: How can create Jar when the User click that Button, I mean how can i excecute Jar command in the Button ActionListener code
You can run pretty much anything using the process api.
@Jan Zyka: Sorry i m unaware of this, please give me any tutorial how to run using process api, and also see my updated comment under my QUESTION, i was confused
On such case you may want to run external program (maybe some .exe) to generate the installation for you. Process api allows you to run external programs.
My point was, that since you can run any program from java in the same manner as from a command line (see the link above) that it might be best on the button click to execute some external program which creates whatever you want for you. You can even execute your AdvancedInstaller if it supports some batch mode.
|