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

Community
  • 1
  • 1
  • So you're planning to write a Java-to-executable compiler? – Piskvor left the building May 18 '11 at 11:44
  • May I ask what would be the point? – Jan Zyka May 18 '11 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 –  May 18 '11 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 ... – Jan Zyka May 18 '11 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 –  May 18 '11 at 11:58
  • @Latha vani: Me too facing same problem,My project is need to create one exe file from that i will get some condition from user and then i have create build menu item,if user click that means another exe file need to be create.i created upto user click build button in first exe,I dont know how to create another exe from that, without using ext tools,Plaese tell me,if u know,Reply is highly rewarded,Thanks in advance – Surej Jul 18 '11 at 18:08

1 Answers1

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)

Jan Zyka
  • 17,460
  • 16
  • 70
  • 118
  • @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 –  May 18 '11 at 11:57
  • You can run pretty much anything using the process api. – Jan Zyka May 18 '11 at 11:58
  • @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 –  May 18 '11 at 12:00
  • 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. – Jan Zyka May 18 '11 at 12:04
  • Can get you help, pls update your answer with detailed explanation Thanks –  May 18 '11 at 12:05
  • How t orun external program from java: http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html – Jan Zyka May 18 '11 at 12:08
  • Mate, pls understand, My question first, i have to generate a Setup file if the user clicks that Button –  May 18 '11 at 12:10
  • 1
    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. – Jan Zyka May 18 '11 at 12:18
  • Jan Zyka: My Question is, So it 's possible to create installer or EXE of the current output, when the user clicks that Button –  May 18 '11 at 12:39