Setting the JVM via the command line on Windows(在 Windows 上通过命令行设置 JVM)
问题描述
是否可以指定调用java jar jar_name.jar"时使用的JVM.我的机器上安装了两个 JVM.我无法更改 JAVA_HOME,因为它可能会破坏已准备好运行的代码.
Is it possible to specify the JVM to use when you call "java jar jar_name.jar" . I have two JVM installed on my machine. I can not change JAVA_HOME as it may break code that is all ready running.
亲切的问候
斯蒂芬
推荐答案
是的 - 只需明确提供 java.exe 的路径.例如:
Yes - just explicitly provide the path to java.exe. For instance:
对正在运行的命令 shell 执行此操作的最简单方法是:
The easiest way to do this for a running command shell is something like:
例如,这是一个完整的会话,显示了我的默认 JVM,然后是路径的更改,然后是新的:
For example, here's a complete session showing my default JVM, then the change to the path, then the new one:
这不会改变显式使用 JAVA_HOME 的程序.
This won't change programs which explicitly use JAVA_HOME though.
请注意,如果您在路径中找到错误的目录 - 包括一个不存在的目录 - 您不会收到任何错误,它实际上会被忽略.
Note that if you get the wrong directory in the path - including one that doesn't exist - you won't get any errors, it will effectively just be ignored.
这篇关于在 Windows 上通过命令行设置 JVM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!