简体   繁体   English

JAVA_HOME libgdx错误macOS Sierra

[英]JAVA_HOME libgdx error macOS Sierra

I'm trying to generate a libgdx project using "project generator" but it shows this error: 我正在尝试使用“项目生成器”生成libgdx项目,但显示此错误:

ERROR: JAVA_HOME is set to an invalid directory: /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

But I have installed the JAVA 1.8, using the terminal command it shows this: 但是我使用终端命令显示了以下内容,从而安装了JAVA 1.8:

$ java -version

java version "1.8.0_101"  
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)    
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

So how to setup the right jvm, someone have any suggestion or the solution to correct this issue? 那么,如何设置正确的jvm,有人有任何建议或解决方案来纠正此问题?

I believe you are using unix type operating system. 我相信您正在使用unix类型的操作系统。 If so do the following steps : 如果是这样,请执行以下步骤:

echo "export JAVA_HOME=`/usr/libexec/java_home`"

If it prints empty like below 如果它打印为空,如下所示

JAVA_HOME=

then you should install java first from oracle site : https://www.oracle.com/technetwork/java/javase/downloads/jdk12-downloads-5295953.html 那么您应该首先从oracle站点安装Java: https : //www.oracle.com/technetwork/java/javase/downloads/jdk12-downloads-5295953.html

If it prints like this : 如果这样打印:

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home

Then you should set your Java Home path like following way : 然后,您应该按照以下方式设置Java Home路径:

export JAVA_HOME=`/usr/libexec/java_home`

Please check this out. 请检查一下。 This link might give you lucid view to set Java Home to valid path. 该链接可以为您提供清晰的视图,以将Java Home设置为有效路径。

mac os how to set java home correctly Mac OS如何正确设置Java Home

Hope this knowledge sharing helps you. 希望这些知识共享对您有所帮助。 Thanks 谢谢

What happens when you type this command in terminal: echo $JAVA_HOME 在终端中键入以下命令会发生什么:echo $ JAVA_HOME

If that is showing the older version of java, you will just need to update your JAVA_HOME settings. 如果显示的是Java的较旧版本,则只需更新JAVA_HOME设置。

Set JAVA_HOME using this command in Terminal: export JAVA_HOME= path to JDK 在终端中使用以下命令设置JAVA_HOME:export JAVA_HOME = JDK的路径

echo $JAVA_HOME on Terminal one more time to confirm the path was changed. 在终端上再回显$ JAVA_HOME一次,以确认路径已更改。

One other thing to keep in mind is sometimes, depending on the programs/projects, you could run into an issue between 32 and 64 bit versions. 需要记住的另一件事是,根据程序/项目的不同,您可能会遇到32到64位版本之间的问题。 You might want to doublecheck you are using the right one. 您可能要仔细检查您使用的是正确的。

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

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