If you have the jre installed on a target platform, say Windows 64 bit, simply copy everything under the
jre folder in your Java install and place it in your distro. Then create a batch file to point to your local jre instead of the system one.
Here is what I do:
- my jar file is in a
- copy the system
- create a .bat file with the following line in it
jre-win-1.7.0_04\bin\java.exe -jar MyProgram.jar
..boom, done! Double click the batch file and it runs your jar file with the local jre. To prove it to yourself, uninstall your system jre and double click the batch file. Still works.
You can do this on Linux or OS X in an analogous way.
I would also like to point out that this is a fairly common practice and many Java distributions are done like this. So, don’t say you can’t or shouldn’t.
There are some caveats, however. This does make your distro larger and platform dependent, in my example Windows x64. However, it’s doable and manageable. There are a finite number of platforms supported for the jre and guess what… they’re platform dependent too.