简体   繁体   English

当用户的“ java”环境变量混乱时该怎么办?

[英]What to do when an user's “java” environment variable is messed up?

Some users, when running a Java project of mine, will be unable to open it. 一些用户在运行我的Java项目时将无法打开它。 When I tell them to use the command line to see the crash message with 当我告诉他们使用命令行查看崩溃消息时,

java -jar myApp.jar

The message is most likely 该消息最有可能

"java" is not a recognised command “ java”不是公认的命令

Or something like that. 或类似的东西。 I've realised that this is probably because, for some reason, their environment variable for "java" is messed up, and they actually can't run any JAR file. 我意识到这可能是由于某种原因,他们的“ java”环境变量搞砸了,他们实际上无法运行任何JAR文件。

I usually walk them through the process of resetting their variable. 我通常会引导他们完成重置变量的过程。 But, ideally, this should never happen. 但是,理想情况下,这永远都不会发生。 Is there a reasonable solution to this? 有合理的解决方案吗? The users HAVE Java - it is just that for whatever reason the environment variable is all wrong. 用户拥有Java-正是由于任何原因,环境变量都是错误的。 Is there a way for my app to, perhaps, workaround this apparently common problem? 我的应用程式是否有办法解决这个看似常见的问题?

You could write a vb script for starting up the java program. 您可以编写一个vb脚本来启动Java程序。 You can get the java executable path and make the vbs launch the java program. 您可以获取Java可执行文件路径,并使vbs启动Java程序。 Refer to this for help with vb script. 有关vb脚本的帮助,请参考此内容

One option can be to install a Java JRE with your application. 一种选择是在您的应用程序中安装Java JRE。

You can provide an executable or startup script that uses the JRE you installed. 您可以提供使用您安装的JRE的可执行文件或启动脚本。

This also ensures that the user is using the JRE that you tested with. 这还可以确保用户正在使用您进行测试的JRE。

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

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