问题描述
echo $ JAVA_HOME给我:
echo $JAVA_HOME gives me:
但是尝试使用此设置将项目导入Intellij无效.我的JAVA HOME是否必须位于
But trying to import a project to Intellij with this setting doesn't work. Does my JAVA HOME have to be in
如果是这样,我该如何使用目前的产品呢?
if so, how do I make it so with what I currently have?
"/usr/libexec/java_home -V"的输出
output of "/usr/libexec/java_home -V"
/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home
推荐答案
3件事适用于JAVA_HOME应该在其中的ENV变量.ENV是一个有范围的字典",它在操作系统上启动的每个进程都被实例化/加载.
3 things apply to your ENV variables in which JAVA_HOME should be. ENV is a scoped 'dictionary' which is instantiated/loaded with every process being started on an OS.
通常通过SYSTEM配置和USER配置加载./etc中的文件被认为是SYSTEM-对于OSX,适用以下规则;最后加载的文件将覆盖以前的值:
It is generally loaded through SYSTEM config and USER config. The files residing in /etc are considered SYSTEM - and for OSX the following applies; last loaded file will overwrite previous values:
首先是/etc/profile,然后存在以下任意一个,按顺序尝试它们:〜/.bash_profile,〜/.bash_login或〜/.profile
First /etc/profile, then whichever of the following exists, trying them in order: ~/.bash_profile, ~/.bash_login, or ~/.profile
/etc/bashrc,然后是〜/.bashrc
/etc/bashrc, then ~/.bashrc
如果实际加载IntelliJ的脚本具有用于设置ENV变量的机制,则当然是带有最后一个单词"的机制.
THEN if the script, that actually loads IntelliJ has a mechanism for setting ENV variables, this will of course be one with the last 'word'.
对于IntelliJ,我认为为此目的使用了一个特定的变量,即IDEA_SDK.因此,将以下内容添加到USER的〜/.profile和〜/.bashrc中:
For IntelliJ i believe a specific variable is used for this purpose, namely IDEA_SDK. So add the following to both ~/.profile and ~/.bashrc for your USER:
export IDEA_SDK=$(/usr/libexec/java_home -v 1.8.0_73)
希望这行得通(确保命令正确无误-mby甚至不考虑版本参数)
Hope this works (make sure the command is just right - mby even just leave out the version arguments)
这篇关于在Mac上为JAVA_HOME的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!