Any way to run an exe made from jar using exe4j from another computer?

心已入冬 提交于 2019-12-14 03:49:41

问题


I've made a little GUI program to enter contents then send "javamail" to my email. I have to import many jar libraries from javamail-1.4.5 and then I build it (shift + f11) to jar, then use exe4j to make it exe (also add all the jars from the libraries in the /dist/lib) and version of jre from 1.5 to 1.7 (I'm using 1.7 to make this app). It works smoothly on my computer but when I give the exe to others computer. It said:

"No JVM could be found on your system. Please define EXE4J_JAVA_HOME to point to an installed 32-bit JDK or JRE or download a JRE from www.java.com"

I think they must install the JDK in order to be able to run the app. But it may be confusing to many of my friends who don't know about computing. Is there anyway can they use that send-javamail-app without asking them to install the JDK?

Thanks in advance and sorry for my English!


回答1:


It's quite simple.

After you have done basic steps as set the name, icon, etc, in step number 6 JRE is where the magic happens:

  1. Click Advanced Options and select Search sequence

  1. Click to add new item + and select directory

  1. Select your jre directory, it must be a relative path

  1. Put your new item at the first position in list

After that what you have to do is release your exe with the jre directory together, to do that usually I use Inno Setup Compiler to create a installer.




回答2:


You can bundle the JRE with your product, this is the best way you can achieve without bothering your buddies. The size of your application will increase.

JRE is required to run any java application.

Hope this helps.




回答3:


Java Runtime Environment (JRE) is required to run the Java application. In order to install JRE on a computer without Java installed, you must either bundle it (put it inside your application), or ask your friends to download JRE.
I don't know exactly how to bundle JRE, but the question Bundling the JRE with a Java application can probably help.




回答4:


Maybe my personal project Java Customization Builder can help you, it analyzes the classes used by your program, and slim these classes from jars, and it also analyzes jvm files used by your program. Then it make an executable file and pack200 the jre runtime and your program.

JCB Project Introduction:

Java Customization Builder is a tool which customizes your java application and JRE.

It is a java application building tool enabling you to generate a very small java archive package which has a slimmed jre. For the swing application, the archive is less than 5M, for the SWT application, the archive is less than 3M usually. And the customed java applicaton can run on the Windows which doesn't install a JRE, and be loaded by an executable.

JCB project page: http://jcb.sourceforge.net



来源:https://stackoverflow.com/questions/13343077/any-way-to-run-an-exe-made-from-jar-using-exe4j-from-another-computer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!