0

When I try to execute my .java program from terminal Mac using command : javac filename.java inputfile

It is throwing the error that "inputfile" are only accepted if annotation processing is explicitly requested

but in the program I do have command as follow:

    String fileinput = args[0];
     File file = new File(fileinput);
    out= getContents(file);     

Thanks in advance

2
  • 1
    You need to use java ClassName inputfile as the command to execute the class. You are currently using javac which is used to compile the .java file. Commented Oct 9, 2021 at 18:54
  • 1
    Oops , thank you . Commented Oct 10, 2021 at 20:23

1 Answer 1

1

When we execute a Java program ProgramName using the following syntax:

java  ProgramName  word0  word1  ...           

the Java system will pass the words:

word0 to the first String parameter variable
word1 to the second String parameter variable
And so on.

But you are using Javac and its compiling .java. You should use java

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

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.