带jar的可移植JVM [英] Portable JVM with jar

查看:158
本文介绍了带jar的可移植JVM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以用jar文件打包JVM或JRE,以便假设用户安装或未安装Java,它将始终使用打包的JVM.我的猜测是,这将需要某种c/c ++程序,而这会剥夺Java的多平台方面.只要平台是Windows,就可以了.同样最好的是,如果用户没有提示安装JVM的程序,程序将启动它,然后在应用程序没有提示用户安装任何东西的情况下启动它.

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. My guess is that it would require some sort of c/c++ program which would take away the multi platform aspect of java. This is fine, as long as the platform is 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.

推荐答案

要在打包JRE时添加@home答案:

To add up to @home answer on packing a JRE:

  1. 压缩操作系统的jre目录(例如,对于Windows:C:\Program Files\Java\jre7)
  2. 将其解压缩到目标计算机上的某个位置(例如D:\MyProgram\jre7)
  3. 可能修改PATH环境变量(例如set PATH=%PATH%;D:\MyProgram\jre7\bin)
  1. zip the jre directory of your OS (e.g. for Windows: C:\Program Files\Java\jre7)
  2. unpack it somewhere on the destination computer (e.g. D:\MyProgram\jre7)
  3. possibly modify the PATH environment variable (e.g. set PATH=%PATH%;D:\MyProgram\jre7\bin)

如果不允许您修改PATH,则只需在启动脚本中明确指定D:\MyProgram\jre7\bin\java.exe -jar MyProgram.jar.

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.

这篇关于带jar的可移植JVM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆