0

I have a java program that is supposed to take an file name from the cmd. My main function looks like this:

public static void main(String[] args) {
        try {
            solve(args);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

The args is a file name that I send it to the function solve. I am using eclipse. I went to Run menu and then, Run Configuration, and I pasted the file path in the Arguments tab for both the Program arguments and the Vm arguments. When I run my program using eclipse, I get the following error:

Error: Could not find or load main class C:\MyFolder\MyFile
2
  • 1
    Please remove it from VM parameters, then all will be fine Commented Jun 30, 2013 at 18:05
  • You just need program arguments. Commented Jun 30, 2013 at 18:05

2 Answers 2

2

You should not add it to the VM arguments. Only to the Program arguments. VM arguments are arguments passed... to the VM. Like memory options, system properties, etc.

Sign up to request clarification or add additional context in comments.

1 Comment

If the file path contains any spaces, you have to enclose the parameter in double quotes.
0

Remove it from VM arguments, program arguments belong to the argumennts box.

VM arguments are arguments to java itselv, e.g. set maximum heap memory to 128MBytes: -Xmx128m

java interprets plain vm arguments as the main class it should execute.

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.