Why must JRE be installed on a machine if it's referenced and packaged in my project?

I exported my project to an executable jar and noticed that eclipse also packaged the external jars I used. When trying to run it on a different machine (which did not have JRE installed), it failed giving the reason that JRE is missing. What is the difference then between the JRE referenced in my project and the JRE I installed from Oracle after I received the error message?

Jon Skeet
people
quotationmark

The JRE is more than just the libraries you're referring to - it's the whole JVM. Also, the JRE wouldn't be included in "external jars" anyway. It's generally assumed that the target of a Java application will already have Java installed - you really wouldn't want to bundle the whole JRE with it, normally.

There are packaging applications which will bundle a JRE with your application - but bear in mind that you'll then have a separate installer for each target platform (OSX, Linux, Windows - and varieties of CPU architecture).

I suggest you look at the jar file that has been created for you - you can rename it to a .zip file and explore it with normal zip file utilities - and then compare its size with the size of a JRE. Unless you're using a really large set of external libraries, I strongly suspect you'll find your application is much smaller than a full JRE.

people

See more on this question at Stackoverflow