I'm quite new to IntelliJ from visual studio, and I'm generally quite confused about how resource files work in an IntelliJ project. I'm read a few questions & answers about getting resources onto the classpath, as well as the IntelliJ docs, but am still confused. I have a few further questions:
main method from within IntelliJ, where does it run it from? Directly from the compiled .class files, or from the generated jar? Where do both those exist in the filesystem, and whats the difference?.xml file somewhere in the source tree, what does IntelliJ do with it by default when compiling and running from within IntelliJ? How can I change where it puts it?main function within IntelliJ?In a Maven project IDE follows Maven rules to process resources so that you will get the consistent results between the command line Maven build and IDEA build. If Maven copies resources to classpath, IDEA will do the same.
From the classpath of the module and its dependencies, normally a .class file is used.
In a non-Maven project resources are copied to the output according to Settings | Compiler | Resource Patterns. In a Maven project resources are handled according to pom.xml resources rules. Files from resources folder are copied automatically. Other folders need to be added to the resources manually using pom.xml.
You can view the classpath in the command line that is printed in the Run console.
In a Maven project use the resources folder. In a non-Maven project the file should be under a source root and its extension needs to be present in the Resource Patterns configuration.
Also note that if you are using a legacy compilation (External Build disabled), IDEA will use Resource Patterns configuration even in Maven projects and the output between IDEA and Maven will be different. The same applies to IDEA 11 and older versions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With