you can achieve this with NSIS
here is another SO post explaining the process in more detail: NSIS script for java installation
In case your project can use Ant, then maybe the antinstaller might be the right choice.
Question
I want to create a windows installer package can be .exe or MSI. I want to do the following :
This is the first time am thinking something like this how this can be accomplished ?
Solution 2
you can achieve this with NSIS
here is another SO post explaining the process in more detail: NSIS script for java installation
In case your project can use Ant, then maybe the antinstaller might be the right choice.
OTHER TIPS
Give Inno Setup a try. A bit challenging at first, but very powerful. There's also many examples around on how you can make it a work with a Java program and check if JRE is installed. And the rest of your requirements are easy to accomplish.
If you want to create an MSI (plus an optional EXE) then I'd recommend looking at the WiX toolset. It's the installation tool that most major companies use including Microsoft.
For deploying Java desktop apps., the best option is usually to install the app. using Java Web Start. JWS works on Windows, OS X & *nix.
To address the specific steps:
Use the deployment toolkit script to check for a suitable minimum JRE, and install if necessary. The script does not (cannot) check for available disk space, but I suspect the JRE installer does.
JWS apps. are installed to the location specified in the Java Control Panel.
This is done automatically, if requested in the launch file. E.G. the two icons on the right hand side (JotPad/Star Zoom) are installed by JWS.
JWS can also install menu items.
Done automatically by JWS.