Intellij IDEA setup on OS X

2019-01-29 23:58发布

问题:

What's the accepted procedure and paths to configure jdk and global library source code for Intellij IDEA on OS X?

回答1:

As of the latest releases:

  • Java for Mac OS X 10.6 Update 3
  • Java for Mac OS X 10.5 Update 8

Apple has moved things around a bit.

To quote the Apple Java guy on the java-dev mailing list:

  1. 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!
  2. 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.
  3. 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
  4. 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.

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



回答2:

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.



回答3:

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.

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.



回答4:

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.

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



回答5:

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