43

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

2
  • 1
    Be carefully not to configure it using symlinked directory, this caused problems in some IntelliJ IDEA versions.
    – sorin
    Nov 25, 2012 at 12:28
  • See the IntelliJ documentation.
    – dimo414
    Jun 13, 2017 at 16:13

5 Answers 5

63

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
  • 12
    You should use /Library/Java/JavaVirtualMachines so IDEA picks up sources and javadoc properly. At the time of this writing, the correct path was /Library/Java/JavaVirtualMachines/1.6.0_22-b04-307.jdk/Contents/Home - The Java Developer Package containing the sources and javadoc is actually hidden quite well. It was available for download at connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wo/… but this may change.
    – Huxi
    Nov 11, 2010 at 10:07
  • @Huxi Your comment is partly, the actual answer. Thanks!
    – Rafay
    Dec 27, 2014 at 19:06
7

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.

1
  • 1
    Just to add a data point, on IDEA 9.0.2 I created a project and it wouldn't let me choose a JDK until after I'd finished creating the project. The widget wouldn't show me any files initially, but I was able to set it up after the project had been created.
    – Lyle
    Jun 28, 2010 at 22:54
4

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.

0

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

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.