Darek Kay
Darek Kay

Reputation: 16669

Different Classloader paths for Eclipse and IntelliJ

Calling

getClass().getResource("./");
// or
getClass().getClassLoader().getResource("./");

from within my JUnit test has different results when executed in Eclipse and IntelliJ IDEA:

All settings appear to be equal:

My resources are located under src/main/resources/mypackage, my JUnit file under src/test/java/mypackage. When executed in Eclipse, the classloader points to the output directory (which contains both java classes and resources). In IntelliJ it points to the src/test/resources source folder.

How can I force IntelliJ to use the output directory for my classloader? Alternatively, how can I force it to use the right source folder src/main/resources where my resources are located?

Upvotes: 1

Views: 1938

Answers (1)

Sanj
Sanj

Reputation: 850

In Intellij, right click on src/main/resources, then select Mark Directory As -> Resources Root

Upvotes: 2

Related Questions