Use of reverse DNS notation in your Intellij project structure
Answered

There's some things I don't fully understand.
ConsiderThe main application, “HelloApplication”,which is in the path:
“src/main/java/dev/research/devcode/HelloApplication.java”
And the FXML view, “hello-view.fxml” which is in the path:
“src/main/resources/dev/research/devcode/view/hello-view.fxml”
And the for the FXML Loader in the main() method:
FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("/dev/research/devcode/view/hello-view.fxml"));
What I do not fully understand:
- why the need for the cascase of empty folders “/dev/research/devcode/” in “src/main/java/dev/research/devcode/HelloApplication.java” when surely it would be better and easier to just have “src/main/java/HelloApplication.java”?
- Why did Intellij add ““/dev/research/devcode/” to my resources package when I did not add it myself? [I added the /view package under this folder cascade to contain all the FXML files.
- [FXMLLoader() path ] For the FXMLLoader() path, why is the path “/dev/research/devcode/”” and not “/resources/dev/research/devcode” ?
- This may seem a fundamental question, but I don't really fully understand I need for it, why the use of the reverse DNS naming style?
Thank you in advance.
Please sign in to leave a comment.
Hi,
With Maven projects, IntelliJ IDEA derives their configuration and structure from
pom.xmlfiles.In your case, a
<sourceDirectory>is probably defined somewhere in the pom file with/dev/research/devcode/in its path. Or some other option that changes the default path.In IntelliJ IDEA, if you use
class.getResource()to obtain a file and if this file resides in a directory marked as a Resource Root, you don't need to pass the entire path in the argument, only the part after the resource root dir.There is no technical reason, only a convention to avoid conflicts. Reverse-DNS names are a simple way of eliminating namespace collisions, since any registered domain name is globally unique to its owner.
Additional reading on the subject:
Merry Christmas!
Thank you.