witek010
witek010

Reputation: 369

java.io.IOException: Cannot run program

I created new java project in Netbeans:

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:

  1. Clean and Build Main Project
  2. 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?

Upvotes: 2

Views: 20373

Answers (4)

Hugh Crawford
Hugh Crawford

Reputation: 1

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.

Upvotes: 0

Yusuf
Yusuf

Reputation: 21

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".

So u should move your project into a new folder like "/Users/xxx/yyy/projectABC/CopyFiles".

Sorry for my English. :-)

Upvotes: 2

sakthisundar
sakthisundar

Reputation: 3288

Just check whether Java is available at

/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

Tools-->Java Platform

and click

Add Platform

and add the Java folder. If you run the program after this, I suppose your program should work.

Upvotes: 2

Peter Lawrey
Peter Lawrey

Reputation: 533492

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.

Can you do

ls -l /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java

Upvotes: 2

Related Questions