Linux 无法识别的选项: - 无法创建 Java 虚拟机
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19089750/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unrecognized option: - Could not create the Java virtual machine
提问by Programatt
I am trying to run my .jar
file on a linux server.
我正在尝试.jar
在 linux 服务器上运行我的文件。
These are the commands I'm running:
这些是我正在运行的命令:
JAVA_HOME=/app/local/opt/jdk/packages/jdk1.6.0_30/
export PATH=$JAVA_HOME/bin:$PATH
cd folder
nohup java -jar program.jar &
When ran on Friday, this was working perfectly. However, today I am getting:
周五运行时,这运行得很好。但是,今天我得到:
Unrecognised option: - Could not create the Java virtual machine.
In my nohup.out
在我的 nohup.out
If I run java -v
after setting the path I get the same problem. Can anyone suggest anything? Really confused about this.
如果我java -v
在设置路径后运行,我会遇到同样的问题。任何人都可以提出任何建议吗?真的很纠结这个。
Thanks for any help on this.
感谢您对此的任何帮助。
回答by orirab
Usually, when we get this kind of exception ("Unrecognised option" which causes the "Could not create the Java virtual machine"), the JVM displays the unrecognized option, like this:
通常,当我们遇到此类异常(“无法识别的选项”导致“无法创建 Java 虚拟机”)时,JVM 会显示无法识别的选项,如下所示:
Unrecognised option: -[option details] Could not create the Java virtual machine.
the fact that you have no details makes it seem as though you just have a space (" ") in your command.
您没有详细信息这一事实使您的命令中似乎只有一个空格 (" ")。
Take a look again to make sure.
再看一遍以确保。
回答by Stephen C
First of all, there is no -v
option on the java
command.
首先,命令-v
上没有选项java
。
(Reference: http://docs.oracle.com/javase/6/docs/technotes/tools/windows/java.html... Java 6 version ... 'cos that is what you are using. Try java -help
for the short list of options.)
(参考:http: //docs.oracle.com/javase/6/docs/technotes/tools/windows/java.html... Java 6 版本 ...'因为这就是你正在使用的。尝试java -help
简短选项列表。)
So it is expected for java -v
to fail.
所以预计java -v
会失败。
As an experiment I tried this (with an OpenJDK Java 8 JDK on Fedora 22):
作为一个实验,我尝试了这个(在 Fedora 22 上使用 OpenJDK Java 8 JDK):
$ java -foop
Unrecognized option: -foop
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
$
As you can see, the "unrecognized option" message tells me what option it doesn't understand. Looking at the message in your question, we see that it is saying it is "-". That doesn't appear to match the command line in your question, but on the other hand the command line in your question does not have any invalid options.
如您所见,“无法识别的选项”消息告诉我它不理解哪个选项。查看您问题中的消息,我们看到它说的是“-”。这似乎与您问题中的命令行不匹配,但另一方面,您问题中的命令行没有任何无效选项。
Another possibility, I guess, is that you have a shell alias called java
. That would take precedence over any commands on the shell's command path.
我猜,另一种可能性是您有一个名为java
. 这将优先于 shell 命令路径上的任何命令。
The other thing is that you are running an ancient version of Java. Java 6 has passed end-of-life, and the last publicly released version is update 45. You are running update 30 which was released in December 2011. There have been LOTS of security patches since then. I'd recommend upgrading to Java 8 ... and making sure that you keep it up to date.
另一件事是您正在运行 Java 的古老版本。Java 6 已结束生命周期,最后一个公开发布的版本是更新 45。您正在运行 2011 年 12 月发布的更新 30。从那时起已经有很多安全补丁。我建议升级到 Java 8 ...并确保您保持最新状态。
回答by ngong
I've got this failure running maven on Win10 where the pom.xml is located in a folder named something like C:\dir\OneDrive - bar\workspace\project
.
我在 Win10 上运行 maven 时遇到了这个失败,其中 pom.xml 位于名为C:\dir\OneDrive - bar\workspace\project
.
Moving the project to a different folder solved it.
将项目移动到不同的文件夹解决了它。