Can I include the rt.jar in my executable jar file and double click to run it without installing java on the machine first ? I hope it to use that rt.jar in my jar to start it self, possible ? If not, any other way ?
views:
103answers:
3The file rt.jar
has Java classes in it (in the form of Java bytecode). In order to interpret the classes, you will need to have Java installed.
Java needs a Java virtual machine (JVM/JRE whatever you want to call it) to run java applications. However, I'm not so sure you need Java to be installed, rather it just be present.
You could provide this alongside your JAR (with a batch file to run the JAR files - as there won't be associations if it's not installed) but it would seriously expand the size of your project.
There are licensing issues to address too.
No, you need a java virtual machine. rt.jar
is also interpreted by the virtual machine and is just the java class library.
If you're looking to turn the code native you might consider gcj which can convert java code to machine code and wrap it up in an exe as per gcc. However, I'm not sure what version of java gcj supports - I've read somewhere it isn't very recent.
It looks like Launch4j can include a bundled JRE, so you might consider this.