Mac OS下IntelliJ运行Scala程序报错,寻求技术解决方案
Hi Rahul, sorry to hear you're hitting this roadblock on your first Scala project—let's break down how to fix this error step by step. The core issue here is that IntelliJ is trying to run a Java executable at a path that doesn't exist (or is inaccessible). Here are the most effective fixes to try:
1. Verify & Fix IntelliJ's JDK Configuration
First, let's make sure the JDK IntelliJ is pointing to actually exists:
- Open IntelliJ and go to
File > Project Structure(use the shortcutCmd + ;on Mac if that's faster). - Switch to the SDKs tab in the left sidebar.
- Look at the path listed for your configured JDK—it should match the one in your error:
/Applications/IntelliJ IDEA CE.app/Contents/jdk/Contents/Home.- If this path doesn't exist in Finder, the bundled JDK that came with your old IntelliJ 2017.3 install is likely corrupted or missing.
- Replace it with a locally installed JDK (stick to JDK 8 or 10, since 2017.3 doesn't support newer JDKs well). To add a new SDK, click the
+icon at the top left, selectJDK, and navigate to the folder where you installed Java (e.g.,/Library/Java/JavaVirtualMachines/jdk1.8.0_XXX.jdk/Contents/Home).
2. Clear IntelliJ's Compile Cache
The error mentions the compile-server cache directory, which might be holding stale or corrupted data:
- Close IntelliJ completely.
- Open Finder, press
Cmd + Shift + G, and paste this path:/Users/rahulghadge/Library/Caches/IdeaIC2017.3/compile-server - Delete the entire
compile-serverfolder. - Alternatively, you can do this from within IntelliJ (before closing it) by going to
File > Invalidate Caches / Restart, then selecting Invalidate and Restart—this will clear all cached data and restart the IDE.
3. Check Module-Level SDK Settings
Sometimes the project-level SDK is correct, but individual modules might still point to the missing JDK:
- Go back to
File > Project Structure > Modules. - Select each module in your Hello World project, switch to the Dependencies tab.
- Look for the Module SDK dropdown—make sure it's set to the working JDK you configured in step 1.
4. Validate System Java Installation
Double-check that your Mac has a working Java installation outside of IntelliJ:
- Open Terminal and run
java -version. - If this command throws an error, you'll need to install a compatible JDK first. Install a stable version like JDK 8, then repeat step 1 to point IntelliJ to this new installation.
A quick note: IntelliJ IDEA 2017.3 is quite old, so using newer JDKs (like 11+) might cause unexpected issues. Sticking to JDK 8 will give you the most stable experience with this IDE version.
内容的提问来源于stack exchange,提问作者Rahul Ghadge

