java Intellij 错误=2 没有那个文件或目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42856555/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 06:54:46  来源:igfitidea点击:

Intellij error=2 No such file or directory

javaintellij-ideajava-8

提问by A.Jac

Installed intellij and added sdk path to project structure, but when i try to run i get:

安装了 intellij 并为项目结构添加了 sdk 路径,但是当我尝试运行时,我得到:

Error: Cannot run program "/home/$USER/java/jdk1.8.0_121/bin/java" 
(in directory"/home/$USER/.intelliJIdea2016.3/system/compile-server"):
error=2, No such file or directory

Both files (/home/$USER/java/jdk1.8.0_121/bin/java and /home/$USER/.intelliJIdea2016.3/system/compile-server) exists.

两个文件(/home/$USER/java/jdk1.8.0_121/bin/java 和/home/$USER/.intelliJIdea2016.3/system/compile-server)都存在。

I am using Ubuntu 16.10

我正在使用 Ubuntu 16.10

回答by UberHans

The answer from here Change jdk path in IntelliJ 13 when compiling from 32 bit program file folder to 64 bit oneworked for me

从这里的答案Change jdk path in IntelliJ 13 whencompile from 32 bit program file folder to 64 bit onework for me

From the menu: File-> Project Structure....

从菜单中:File-> Project Structure...

On the left, below "Platform Settings", you have "SDKs": click on it; you can add your new JDK here.

在左侧,“平台设置”下方,您有“SDK”:单击它;您可以在此处添加新的 JDK。

Always in the same window, below "Project Settings", select "Project": you have the option to select the JDK which you just added.

始终在同一窗口中,在“项目设置”下方,选择“项目”:您可以选择刚刚添加的 JDK。

回答by Luis Solano

In my case, IntelliJ was pointing to a JDK folder of a version I had uninstalled. For some reason the uninstaller didnt remove the Java/jdk* folder, so it was not showing any error in the configuration screen File -> Project Structure -> SDK

就我而言,IntelliJ 指向我已卸载版本的 JDK 文件夹。由于某种原因,卸载程序没有删除 Java/jdk* 文件夹,因此在配置屏幕 File -> Project Structure -> SDK 中没有显示任何错误

After finding out it was pointing to an uninstalled JDK folder then I proceeded to adjust this configuration thanks to the answer posted by UberHans

在发现它指向一个已卸载的 JDK 文件夹后,由于 UberHans 发布的答案,我继续调整此配置

回答by Yao Li

Make sure your JDK path is correct. In my case, it updated JDK version somehow but I didn't notice it, there are a lot of red underlines. After I edit JDK with the correct path, the world became green.

确保您的 JDK 路径正确。就我而言,它以某种方式更新了 JDK 版本,但我没有注意到,有很多红色下划线。用正确的路径编辑JDK后,世界变绿了。