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 se开发者_开发百科lf, possible ? If not, any other way ?
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.
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.
The 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.
精彩评论