开发者

Is it possible to run an executable jar file on a machine without installing java first?

开发者 https://www.devze.com 2022-12-21 13:02 出处:网络
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, pos

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消