如何在发布之前检查JRE版本? [英] How to check JRE version prior to launch?

查看:248
本文介绍了如何在发布之前检查JRE版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

确定计算机上安装的JRE版本是否足以满足用户想要运行的应用程序的最佳方法是什么?有没有办法使用java-only的东西呢?我希望该解决方案适用于Windows / Linux / MacOSX - 如果JRE版本太低,则应显示消息。目前,如果我尝试在Java 1.5上运行它(该应用程序是为Java 1.6构建的),我会遇到异常。如果没有通用解决方案,那么在Windows上执行此操作的最佳方法是什么?

What's the best way to determine if the version of the JRE installed on a machine is high enough for the application which the user wants to run? Is there a way of doing it using java-only stuff? I'd like the solution to work on Windows/Linux/MacOSX - if the JRE version is too low a message should be displayed. Currently I'm getting an exception if i try to run it on Java 1.5 (the app is built for Java 1.6). If there's no universal solution, what's the best way to do it on Windows?

推荐答案

为更高版本的JRE构建的应用程序不会在较低版本的JRE上运行。因此,您无法仅将代码添加到应用程序以检查JRE版本 - 如果JRE版本不兼容,则JRE版本检查代码将不会首先运行。

An application built for a higher-version JRE will not run on a lower-version JRE. So you wouldn't be able to just add code to your application to check the JRE version - if the JRE version was incompatible, your JRE-version-checking code would not run in the first place.

你需要做的是有一些为较低版本的JRE(1.3?)构建的启动器应用程序,它会检查版本,然后在必要时启动你的应用程序。这对我来说听起来很糟糕。

What you'd have to do is have some sort of launcher application that is built for a lower-version JRE (1.3?) that checks the version and then launches your app if necessary. This sounds kind of kludgy to me.

在安装过程中检查版本怎么样?您是否以允许检查环境变量或执行任何脚本编写的方式安装应用程序?

What about checking the version during installation? Are you installing the app in a way that allows you to check environment variables, or do any sort of scripting?

这篇关于如何在发布之前检查JRE版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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