getResourceAsStream returning null in Java 10

The class of that variable is a system class and it is loaded by a different class loader.

You should use one of your own classes.


I found a solution although I don't entirely understand why this works an the problematic line doesn't, but this works:

Application.class.getResourceAsStream("/application.properties")

where Application is just a class in my app.

Maybe this is related to the answer pointed to by ochi, and Application.class is using my class loader and appProperties.getClass() is using the system class loader. But why does it behave differently on differently on Java 8 vs 10 is not something that is apparent.

Tags:

Java

Java 10