[英]Portable JVM with jar
Is it possible to pack a JVM or JRE with a jar file so that assuming the user does or doesn't have Java installed, it will always resort to the packed JVM. 是否可以用jar文件打包JVM或JRE,以便假设用户已安装或未安装Java,它将始终使用打包的JVM。 My guess is that it would require some sort of c/c++ program which would take away the multi platform aspect of java.
我的猜测是,这将需要某种c / c ++程序,而这会剥夺Java的多平台方面。 This is fine, as long as the platform is Windows.
只要平台是Windows,就可以了。 Also it would be best if the user doesn't get a prompt to install the JVM, the program just launches it and then the application with no prompt for the user to install anything.
同样最好的是,如果用户没有提示安装JVM,程序只是启动它,然后应用程序又没有提示用户安装任何东西。
To add up to @home answer on packing a JRE: 要在打包JRE时总计@home答案:
jre
directory of your OS (eg for Windows: C:\\Program Files\\Java\\jre7
) jre
目录(例如,对于Windows: C:\\Program Files\\Java\\jre7
) D:\\MyProgram\\jre7
) D:\\MyProgram\\jre7
) PATH
environment variable (eg set PATH=%PATH%;D:\\MyProgram\\jre7\\bin
) PATH
环境变量(例如, set PATH=%PATH%;D:\\MyProgram\\jre7\\bin
) If you're not allowed to modify PATH
, you can just explicitly specify D:\\MyProgram\\jre7\\bin\\java.exe -jar MyProgram.jar
in a startup script. 如果不允许您修改
PATH
,则只需在启动脚本中显式指定D:\\MyProgram\\jre7\\bin\\java.exe -jar MyProgram.jar
。
This is fine, as long as the platform is Windows.
只要平台是Windows,就可以了。
If all you want to support is Windows, what is the attraction of Java (as opposed to, for example, .Net)? 如果您只想支持Windows,那么Java(与.Net相对)的吸引力是什么?
Also it would be best if the user doesn't get a prompt to install the JVM, ..
如果用户没有提示安装JVM的话,那也是最好的。
Not according to this user. 并非根据此用户。 Ever heard of UAC?
听说过UAC吗? If my fully enabled UAC failed to catch that and prompt me, I'd be raising a bug report with MS.
如果我完全启用的UAC无法捕获并提示我,我将向MS提出错误报告。
Oracle provides the deployJava.js to ensure that a suitable minimum version of the JRE is installed before running an applet or providing a launch button for java-web-start apps. Oracle提供了deployJava.js,以确保在运行小程序或为java-web-start应用程序提供启动按钮之前,已安装合适的最低JRE版本。 You might adapt the 2nd function to link directly to the executable Jar.
您可以修改第二个函数以直接链接到可执行的Jar。
I am ware of 2 different approaches: 我知道2种不同的方法:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.