How to include a JVM in JAR file if Java is not installed on user machine?

include, jar, java, jvm

Solution

You can't include the JVM in the JAR file. You can, however, put the JRE in your distribution next to the JAR file - assuming you know what platform (OS, processor) the distribution is intended for. On how to do that, you can read here.

Problem

Maybe the question sounds a bit strange... I would like to distribute my Java application. I know how to generate a jar file, but it only includes my classes. What if the user does not have java installed on its computer ? So what I would like to know is how to include the JVM in my JAR file. Or find the equivalent correct way of doing this. I found almost nothing about this so I'm probably asking the wrong question... Many thanks !

Original source