简体   繁体   English

如何使Java应用程序独立?

[英]How to make Java application standalone?

I have to burn a Java application on a CD. 我必须在CD上刻录Java应用程序。 This application have to run on every Windows PC wihtout any installation (also JRE shouldn't be installed) before. 此应用程序必须在每台Windows PC上运行,无需任何安装(也不应安装JRE)。

I guess you could copy the JRE from your programs folder onto the CD too. 我想你也可以将JRE从你的程序文件夹复制到CD上。 Then, add a batch script to use your "local" JRE to start your app. 然后,添加批处理脚本以使用“本地”JRE启动您的应用程序。 That should be enough, but I don't know if this works with all versions of windows. 这应该足够了,但我不知道这是否适用于所有版本的Windows。

You'd have to bundle jre on disk and create startup scripts. 您必须将jre捆绑在磁盘上并创建启动脚本。 If you are not satisfied with simple batch / shell startup scripts you can use something like JLauncher to create "real" executable. 如果您对简单的批处理/ shell启动脚本不满意,可以使用类似JLauncher的东西来创建“真正的”可执行文件。

JSmooth can do the trick with bundling JRE or prompting install Java, and it is free . JSmooth可以通过捆绑JRE或提示安装Java来实现这一目的,而且它是免费的 You can also set properties for JVM 您还可以设置JVM的属性

The easiest way would be to include an unpacked Java installation on the CD and use it to run the application. 最简单的方法是在CD上包含一个解压缩的Java安装,并使用它来运行应用程序。

There are AFAIK only 2 "Java to exe" compilers still on the market, one of which (Excelsior JET) is quite expensive, and the other (GCJ) doesn't work on Programs that use AWT or Swing. AFAIK只有2个“Java to exe”编译器仍然在市场上,其中一个(Excelsior JET)非常昂贵,而另一个(GCJ)不适用于使用AWT或Swing的程序。

只需将jre刻录到cd上,然后在批处理脚本中启动应用程序,该脚本将CLASSPATH和JAVA_HOME变量设置为指向jre。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM