2

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?

1
  • Seems like classpath for Java_home is not set properly. It seems the classpath has set java_home to /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java, but java is not actually available at that location. Commented Aug 6, 2012 at 11:21

4 Answers 4

2

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
Sign up to request clarification or add additional context in comments.

Comments

2

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.

Comments

2

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. :-)

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.