Unable to set project SDK in Intellij

廉价感情. 提交于 2020-01-02 10:18:14

问题


I was earlier running my project using Java 1.7 but now I have to upgrade it to version 1.8. I have it installed as an alternative installation on my CentOS.
The location of Java8 is at /opt/jdk1.8.0_25/ and the current Java is at /usr/java/jdk1.7.0_67/. My system's JAVA_HOME also points to /usr/java/jdk1.7.0_67/.

As soon as I add the new SDK I get this error: Cannot Save Settings: Please specify a different SDK name.

How should I solve this issue?


回答1:


This means you already have a SDK with this name (cause the messge key in jetbrains is : sdk.list.unique.name.required.error).

Remove the SDK before creating it once again.

To configure SDKs at the global (IDE) level

  1. Open the Project Structure dialog (e.g. Ctrl+Shift+Alt+S).
  2. In the left-hand pane, under Platform Settings, click SDKs.
  3. To add a new SDK, click add and select the desired SDK type.
  4. In the dialog that opens, select the SDK home directory and click OK. As a result, a new SDK is added to IntelliJ IDEA, and its settings are shown on the SDK page in the right-hand part of the dialog.
  5. Optionally, edit the SDK name and contents.
  6. If necessary, add more SDKs as described above.
  7. Click OK in the Project Structure dialog.

To configure a project SDK

  1. Open the Project Structure dialog (e.g. Ctrl+Shift+Alt+S).
  2. In the left-hand pane, under Project Settings, click Project.
  3. On the page that opens in the right-hand part of the dialog, select the necessary SDK from the Project SDK list.
  4. If the desired SDK is not present in the list, click New and select the necessary SDK type.
  5. In the dialog that opens, select the SDK home directory and click OK. As a result, a new SDK is added to IntelliJ IDEA and selected as the project SDK.
  6. To view or edit the SDK name and contents, click Edit. (The SDK page will open.)
  7. Click OK in the Project Structure dialog.

Source : IntelliJ IDEA 14.1.1 Help/Configuring Global, Project and Module SDKs




回答2:


I saw another situation that caused the same Intellij error when trying to add a new JDK:

Cannot Save Settings: Please specify a different SDK name.

In this case the problem was that there were already two JDKs listed with exactly the same name "1.8". (How this happened I don't know.) It was not a problem with the new JDK 11 that I was trying to add.

Once I deleted the duplicate JDK 1.8 from within "Project Structure... -> Platform Settings -> SDKs", I was then able to complete saving the newly added JDK 11.

I've added this in case it is useful to people encountering this Intellij error.



来源:https://stackoverflow.com/questions/31506278/unable-to-set-project-sdk-in-intellij

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!