macos Mac OS 上的 IntelliJ IDEA JDK 配置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4481951/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 07:28:07  来源:igfitidea点击:

IntelliJ IDEA JDK configuration on Mac OS

macosintellij-idea

提问by Josh Morrison

I am using IntelliJ IDEA 10. Every time when I create a new project, it is asking me to choose JDK for this project. Anyone know how I can configure it and make it easy to use?

我使用的是 IntelliJ IDEA 10。每次创建新项目时,都会要求我为该项目选择 JDK。有谁知道我如何配置它并使其易于使用?

回答by CrazyCoder

If you are on Mac OS X or Ubuntu, the problem is caused by the symlinks to the JDK. File | Invalidate Caches should help. If it doesn't, specify the JDK path to the direct JDK Home folder, not a symlink.

如果您使用的是 Mac OS X 或 Ubuntu,则问题是由 JDK 的符号链接引起的。档案 | 无效缓存应该会有所帮助。如果没有,请指定直接 JDK 主文件夹的 JDK 路径,而不是符号链接。

Invalidate Cachesmenu item is available under IntelliJ IDEA Filemenu.

Invalidate Caches菜单项在 IntelliJ IDEA File菜单下可用。

Direct JDK path after the recent Apple Java update is:

最近 Apple Java 更新后的直接 JDK 路径是:

/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

In IDEA you can configure the new JSDK in File | Project Structure, select SDKson the left, then press [+]button, then specify the above JDK home path, you should get something like this:

在 IDEA 中你可以在File | 中配置新的 JSDK Project Structure,在左边选择SDKs,然后按[+]按钮,然后指定上面的JDK home路径,你应该得到这样的:

JDK 1.6 on Mac

Mac 上的 JDK 1.6

回答by ehanoc

Just tried this recentlyand when trying to select the JDK... /System/Library/Java/JavaVirtualMachines/appears as emptywhen opening&selecting through IntelliJ. Therefore i couldn't select the JDK...

最近刚刚尝试过这个,当尝试选择JDK...通过IntelliJ打开和选择时/System/Library/Java/JavaVirtualMachines/显示为。因此我无法选择JDK ...

I've found that to workaroundthis, when the finder windows open (pressing [+]JDK) just use the shortcut Shift + CMD + Gto specify the path. (/System/Library/Java/JavaVirtualMachines/1.6.0.jdkin my case)

我发现要解决这个问题,当 finder 窗口打开时(按[+]JDK)只需使用快捷键Shift + CMD + G来指定路径。(/System/Library/Java/JavaVirtualMachines/1.6.0.jdk在我的情况下)

And voila, IntelliJ can find everything from that point on.

瞧,IntelliJ 可以从那时起找到所有内容。

回答by some random guy

The JDK path might change when you update JAVA. For Mac you should go to the following path to check the JAVA version installed.

更新 JAVA 时,JDK 路径可能会更改。对于 Mac,您应该到以下路径检查安装的 JAVA 版本。

/Library/Java/JavaVirtualMachines/

Next, say JDK version that you find is jdk1.8.0_151.jdk, the path to home directory within it is the JDK home path.

接下来,假设您找到的 JDK 版本是jdk1.8.0_151.jdk,其中主目录的路径是 JDK 主路径。

In my case it was :

就我而言,它是:

/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home

You can configure it by going to File -> Project Structure -> SDKs.

您可以通过转到配置它File -> Project Structure -> SDKs

enter image description hereenter image description here

在此处输入图片说明在此处输入图片说明

回答by ViliusK

On Mac IntelliJ Idea 12 has it's preferences/keymaps placed here: ./Users/viliuskraujutis/Library/Preferences/IdeaIC12/keymaps/

在 Mac IntelliJ Idea 12 上,它的首选项/键盘映射放置在这里:./Users/viliuskraujutis/Library/Preferences/IdeaIC12/keymaps/