My project has the following structure:
src/test/resources/utility/configuration.xml
I am trying to get the file location in the system using ClassLoader
public File getFileFromResources(String fileName){
        ClassLoader classLoader = getClass().getClassLoader();
        URL resource = classLoader.getResource(fileName);
        if(resource == null){
            throw new IllegalArgumentException("file not found");
        }else{
            return new File(resource.getFile());
        }
Calling method:
File file = getFileFromResources("Utility/ConfigurationXML.xml");
strFilePath = file.getAbsolutePath();
which gives me the absolute path of the file, which is in the target folder.
The above code works fine in eclipse IDE, but when I created the project JAR, getFileFromResources() returns me
file:/C:/Users/UserName/Desktop/ExecutableJAR/TestJAR-tests.jar!/Utility/ConfigurationXML.xml
I am using Maven to build my project.
 
     
     
     
    