java.io.IOException:无法运行程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11827218/
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
java.io.IOException: Cannot run program
提问by witek010
I created new java project in Netbeans:
我在 Netbeans 中创建了新的 java 项目:
package copyfiles;
import java.io.File;
import java.io.FileInputStream;
public class CopyFiles {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
}
}
And I selected:
我选择了:
- Clean and Build Main Project
- Run Main Project
- 清理并构建主项目
- 运行主项目
I have an error:
我有一个错误:
java.io.IOException: Cannot run program "/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java" (in directory "/Users/xxx/yyy/kopiowanie plików/CopyFiles"): error=2, No such file or directory
What is wrong?
怎么了?
回答by Peter Lawrey
My guess is you have mis configured where to find the JDK used to run your program as the java
you are trying to use doesn't exist.
我的猜测是您错误地配置了在哪里可以找到用于运行您的程序的 JDK,因为java
您尝试使用的 JDK不存在。
Can you do
你可以做
ls -l /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java
回答by sakthisundar
Just check whether Java is available at
只需检查 Java 是否可用
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java
or not. I don't think it is available. If it is not there and if someone has changed the java folder name, n your Netbeans IDE go to
或不。我不认为它可用。如果它不存在并且有人更改了 java 文件夹名称,请在您的 Netbeans IDE 中转到
Tools-->Java Platform
工具-->Java平台
and click
并点击
Add Platform
添加平台
and add the Java folder. If you run the program after this, I suppose your program should work.
并添加Java文件夹。如果您在此之后运行该程序,我想您的程序应该可以运行。
回答by Yusuf
I think I've got the reason.
我想我是有理由的。
It likely to Netbeans cannot support Non-Ascii path.Path part "kopiowanie plików" cannot be accepted in this path "/Users/xxx/yyy/kopiowanie plików/CopyFiles".
Netbeans 可能无法支持非 Ascii 路径。在此路径“/Users/xxx/yyy/kopiowanie plików/CopyFiles”中不能接受路径部分“kopiowanie plików”。
So u should move your project into a new folder like "/Users/xxx/yyy/projectABC/CopyFiles".
所以你应该将你的项目移动到一个新文件夹中,比如“/Users/xxx/yyy/projectABC/CopyFiles”。
Sorry for my English. :-)
对不起我的英语不好。:-)
回答by Hugh Crawford
Had this problem. I actually had 2, but fixed the first one. In the process a website suggested setting the "Run as Administrator" in the compatibility settings for "java.exe" in the bin folder. I fixed the first problem, but still had this error until I turned off the "Run as Administrator" option. Now it's working.
有这个问题。我实际上有 2 个,但修复了第一个。在此过程中,网站建议在 bin 文件夹中“java.exe”的兼容性设置中设置“以管理员身份运行”。我解决了第一个问题,但在关闭“以管理员身份运行”选项之前仍然出现此错误。现在它正在工作。