getResource() is returning null with Gradle project

Create a folder called "resources" in the same Location that java folder exist in the main folder of the project. and locate all the images and other resources into the "resources" folder. the get those like this

new ImageIcon(getClass().getClassLoader().getResource("image.png"));

If you pass a resource path that doesn't start with a / to Class.getResource(), the class loader looks for the resource in the package of the class. Not at the root. Your code should be

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

or

this.getClass().getClassLoader().getResource("checkstyle_whitespace.xml")