Package structure should be same as directory structure in Java it seems in Eclipse.
I tried to browse through the formal documentation on Oracle Java docs but nowhere I could find this rule
Does this rule extend to other IDEs such as Netbeans or is this a rule of Java language itself?
How strict is this rule, can it be deviated from and why was it made?
It’s specified in the JLS as a rule that compilers may require:
For example, if you specify all the source filenames on the command line for javac, you don’t have to follow those rules… but it’s pretty much universally used, and I wouldn’t dream of violating this rule for anything other than tiny tests.
Note that by default, javac will generate the class file as a peer of the source file, regardless of package structure; if you specify
-dit will generate the appropriate output structure even if it doesn’t match the source structure.