在 Intellij IDEA 14.1.4 中:无法运行程序“C:/Program Files (x86)/Java/jdk1.8.0_45/bin/java”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31238144/
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
In Intellij IDEA 14.1.4: Cannot run program "C:/Program Files (x86)/Java/jdk1.8.0_45/bin/java"
提问by Matt Kindy
I am trying to run a java-based Play 2.0 app in IDEA, but upon compilation, I get this error:
我试图在 IDEA 中运行基于 Java 的 Play 2.0 应用程序,但在编译时,我收到此错误:
Information:Internal caches are corrupted or have outdated format, forcing project rebuild: Module 'web-server' production: java.io.IOException: Cannot run program "C:/Program Files (x86)/Java/jdk1.8.0_45/bin/java" (in directory "C:\Users\\Documents\GitHub\\web-server"): CreateProcess error=267, The directory name is invalid
信息:内部缓存已损坏或格式过时,迫使项目重建:模块“web-server”生产:java.io.IOException:无法运行程序“C:/Program Files (x86)/Java/jdk1.8.0_45/bin /java”(在目录“C:\Users\\Documents\GitHub\\web-server”中):CreateProcess error=267,目录名无效
This occurs during a ProcessBuilder.start()
action.
这发生在一个ProcessBuilder.start()
动作中。
I have made sure all the path variables are properly set, even changing them up to ensure that they work properly. The thing that gets me here is that it seems like ProcessBuilder is trying to use forward slash paths, but I'm running in Windows.
我确保所有路径变量都已正确设置,甚至更改它们以确保它们正常工作。让我在这里的事情是 ProcessBuilder 似乎正在尝试使用正斜杠路径,但我在 Windows 中运行。
I've tried reloading my project from scratch, invalidating the cache and restarting, updating my java installation (both 32- and 64-bit), and uninstalling and reinstallating IDEA, but it just won't seem to work. This same project runs fine on another computer, so I'm thinking it might be a local issue. Any help would be greatly appreciated!
我尝试从头开始重新加载我的项目,使缓存无效并重新启动,更新我的 java 安装(32 位和 64 位),以及卸载并重新安装 IDEA,但它似乎不起作用。同样的项目在另一台计算机上运行良好,所以我认为这可能是本地问题。任何帮助将不胜感激!
采纳答案by neandertal
I had the same issue, here is how I solved it:
我遇到了同样的问题,这是我解决的方法:
Clearly there is something wrong with the directory path. Mine was "D:\IntelliJ Workspace\" but in error message it was "D:\IntelliJ+Workspace\". When I remove the space in directory name the error was fixed.
显然目录路径有问题。我的是“D:\IntelliJ Workspace\”,但在错误消息中它是“D:\IntelliJ+Workspace\”。当我删除目录名称中的空格时,错误已修复。
In your situation "C:\Users\\Documents\GitHub\\web-server" has extra back slashes so when you fix this, I think your error will be fixed.
在您的情况下,“C:\Users\\Documents\GitHub\\web-server” 有额外的反斜杠,因此当您解决此问题时,我认为您的错误将得到解决。
回答by fresko
I had this problem recently, i solved in 2 steps.
我最近遇到了这个问题,我分两步解决了。
Part 1
第1部分
If your path JAVA_HOME is OK:
如果您的路径 JAVA_HOME 没问题:
File → Settings → Build, Execution, Deployment → Build Tools → Maven → Runner
文件 → 设置 → 构建、执行、部署 → 构建工具 → Maven → Runner
Set to "use JAVA_HOME (...Path...)"
设置为“使用 JAVA_HOME (...Path...)”
If you set with a fixed string, the problem may reappear when in future you will re-update. Anyway, you can do that.
如果您设置了固定字符串,那么在您以后重新更新时可能会再次出现该问题。无论如何,你可以这样做。
Part 2
第2部分
File → Other Settings → Default Project Structure
文件 → 其他设置 → 默认项目结构
Check all the tabs and ensure that all the path point to the newly installed JDK (If you change in one, then you should have all changed, e.g. i changed in Annotations)
检查所有选项卡并确保所有路径都指向新安装的JDK(如果您更改了一个,那么您应该全部更改,例如我在注释中更改)
If you cannot select the path (error: not valid path), try not to use the one in C:\Program Files (x86)\Java...\ -- select the one in C:\Program Files\Java...\ (or viceversa)
如果无法选择路径(错误:无效路径),请尽量不要使用 C:\Program Files (x86)\Java...\ 中的那个——选择 C:\Program Files\Java.. 中的那个。 。\ (或相反亦然)
回答by Dinu94
Had the same issue as the folder containing the project has spaces in its name. Worked perfectly after removing the spaces and renaming it.
与包含项目的文件夹名称中包含空格的问题相同。删除空格并重命名后完美运行。
回答by Rajesh Kumar
i changed from jdk1.7 to jdk1.8.0_212 and it worked however during compile time i am usind jdk 1.7 and in run time its jdk1.8.0_212
我从 jdk1.7 更改为 jdk1.8.0_212 并且它在编译时工作但是我使用 jdk 1.7 并且在运行时它的 jdk1.8.0_212
回答by Omer Sonmez
I had same issue with idea 14.1.4. Changing Maven Runner option to Use JAVA_HOME helped. Settings > Maven > RunnerSet JRE to Use JAVA_HOME.
我对想法 14.1.4 有同样的问题。将 Maven Runner 选项更改为 Use JAVA_HOME 有帮助。 设置 > Maven > Runner将 JRE 设置为使用 JAVA_HOME。