Question

In Java, Eclipse, what location does this line of code refer to?

this.getClass().getResource()

Does it give me the project folder? Or the package folder? Or anything else?

How exactly should one work with this?

No correct solution

OTHER TIPS

this.getClass().getResource("/")

it refers to root of your output directory (target/classes or any other output directory configured in your ide configuration if IDE is the case)

the same directory where your class file is located.

for example, you have an eclipse project with a x.y.z.My.java in the src dir

if it's compiled to x.y.z.My.class in the bin dir

then if this() is My.class, this will point to bin/x/y/z

GetResources is reffering to the location related all the packages in your CLASSPATH it means target/classes. Classpath and target can be configured depends on the IDE. For instance for Intellij : project properties->modules->paths

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top