Benno
Benno

Reputation: 5456

How to disable javac file name checking?

If a public class is defined in a file with the wrong filename, javac will throw an error:

square_supplies.java:5: error: class Answer is public, should be declared in a file named Answer.java

Is there a flag to turn off this behaviour? If it's not possible for javac, is there another java compiler where this can be turned off?

Upvotes: 4

Views: 482

Answers (1)

MTilsted
MTilsted

Reputation: 5543

No, this is part of the java language. If the public class Answer is not in Answer.java, then the javac compiler have no way to know where the class Answer is located. And it need that information when compiling classes which depend on Answer.

Upvotes: 6

Related Questions