Java OS X 上的 Intellij IDEA 设置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/470882/
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
Intellij IDEA setup on OS X
提问by James Allman
What's the accepted procedure and paths to configure jdk and global library source code for Intellij IDEA on OS X?
在 OS X 上为 Intellij IDEA 配置 jdk 和全局库源代码的可接受程序和路径是什么?
采纳答案by Rohan
As of the latest releases:
截至最新发布:
- Java for Mac OS X 10.6 Update 3
- Java for Mac OS X 10.5 Update 8
- 适用于 Mac OS X 10.6 更新 3 的 Java
- 适用于 Mac OS X 10.5 更新 8 的 Java
Apple has moved things around a bit.
苹果已经改变了一些东西。
To quote the Apple Java guy on the java-dev mailing list:
引用 java-dev 邮件列表中的 Apple Java 人的话:
System JVMs live under /System/Library/...
- These JVMs are only provided by Apple, and there is only 1 major platform version at a time.
- The one version is always upgraded, and only by Apple Software Updates.
- It should always be GM version, that developers can revert back to, despite any developer previews or 3rd party JVMs they have installed.
- Like everything else in /System, it's owned by root r-x, so don't mess with it!
Developer JVMs live under /Library/Java/JavaVirtualMachines
- Apple Java Developer Previews install under /Library.
- The Developer .jdk bundles contain everything a developer could need (src.jar, docs.jar, etc), but are too big to ship to the tens of millions of Mac customers.
- 3rd party JVMs should install here.
Developers working on the JVM itself can use ~/Library/Java/JavaVirtualMachines
- It's handy to symlink to your current build product from this directory, and not impact other users
Java IDEs should probably bias to using /Library or ~/Library detected JVMs, but should be able to fallback to using /System/Library JVMs if that's the only one installed (but don't expect src or JavaDoc).
This allows Java developers the maximum flexibility to install multiple version of the JVM to regress bugs and even develop a JVM on the Mac themselves. It also ensures that all Mac customers have one safe, slim, secure version of the JVM, and that we don't endlessly eat their disk space every time we Software Update them a JVM.
系统 JVM 位于 /System/Library/...
- 这些 JVM 仅由 Apple 提供,并且一次只有 1 个主要平台版本。
- 一个版本总是会升级,而且只能通过 Apple 软件更新。
- 它应该始终是 GM 版本,开发人员可以恢复到,不管他们安装了任何开发人员预览或 3rd 方 JVM。
- 与 /System 中的所有其他内容一样,它归根 rx 所有,所以不要惹它!
开发人员 JVM 位于 /Library/Java/JavaVirtualMachines 下
- Apple Java Developer Previews 安装在 /Library 下。
- Developer .jdk 包包含开发人员可能需要的所有内容(src.jar、docs.jar 等),但太大而无法提供给数千万 Mac 客户。
- 第 3 方 JVM 应该安装在这里。
在 JVM 本身上工作的开发人员可以使用 ~/Library/Java/JavaVirtualMachines
- 从此目录符号链接到您当前的构建产品很方便,并且不会影响其他用户
Java IDE 可能倾向于使用 /Library 或 ~/Library 检测到的 JVM,但如果这是唯一安装的 JVM,则应该能够回退到使用 /System/Library JVM(但不要指望 src 或 JavaDoc)。
这使 Java 开发人员可以最大程度地灵活地安装多个版本的 JVM 以修复错误,甚至可以自己在 Mac 上开发 JVM。它还确保所有 Mac 客户都拥有一个安全、纤薄、安全的 JVM 版本,并且我们不会在每次软件更新 JVM 时无休止地占用他们的磁盘空间。
So, instead of pointing Intellij at /System/Library/Frameworks/JavaVM.framework, you should point to a JDK in either /Library/Java/JavaVirtualMachines or /System/Library/Java/JavaVirtualMachines
因此,不是将 Intellij 指向 /System/Library/Frameworks/JavaVM.framework,您应该指向 /Library/Java/JavaVirtualMachines 或 /System/Library/Java/JavaVirtualMachines 中的 JDK
回答by osi
IntelliJ should detect your installed JDK's, as they are in a standard location that Apple provides. If you want source code for the JDK, you can download that from Apple as well. Sign up for a free ADC account and then you can get access.
IntelliJ 应该检测您安装的 JDK,因为它们位于 Apple 提供的标准位置。如果您需要 JDK 的源代码,也可以从 Apple 下载。注册一个免费的 ADC 帐户,然后您就可以访问了。
For global libraries, I've been enjoying the Maven integration in the recent release. It alleviates the need to setup global libraries by pulling things from the Maven repository. It will download source and javadoc jars as well.
对于全局库,我一直在享受最近版本中的 Maven 集成。它通过从 Maven 存储库中提取东西来减轻设置全局库的需要。它还将下载源代码和 javadoc jar。
回答by Stefan Arentz
In the 'Project Settings' window, go to 'JDKs' section that you see under'Platform Settings'. Click the little plus sign and choose 'JSDK'. A file chooser should open in the /System/Library/Frameworks/JavaVM.framework/Versions directory. If not then just navigate to it. There you can choose the version you would like to add.
在“项目设置”窗口中,转到您在“平台设置”下看到的“JDK”部分。单击小加号并选择“JSDK”。文件选择器应在 /System/Library/Frameworks/JavaVM.framework/Versions 目录中打开。如果没有,那么只需导航到它。在那里您可以选择要添加的版本。
回答by Dustin Getz
the JDK that comes with osx doens't include the source. you need to log into the apple developer site with your apple account to find the developer version of the SDK which includes src.jar.
osx 附带的 JDK 不包含源代码。您需要使用您的苹果账号登录苹果开发者网站,找到包含 src.jar 的 SDK 的开发者版本。
http://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wo/5.1.17.2.1.3.3.1.0.1.1.0.3.1.3.3.1
http://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wo/5.1.17.2.1.3.3.1.0.1.1.0.3.1.3.3.1
回答by Rejeev Divakaran
The post from intellij support page explains how to configure the JDK which Intellij uses to run itself. https://intellij-support.jetbrains.com/entries/23455956-Selecting-the-JDK-version-the-IDE-will-run-under
Intellij 支持页面的帖子解释了如何配置 Intellij 用来运行自身的 JDK。 https://intellij-support.jetbrains.com/entries/23455956-Selecting-the-JDK-version-the-IDE-will-run-under