Skip to content
Advertisement

open resource with relative path in Java

In my Java app I need to get some files and directories.

This is the program structure:

JavaScript

guiclass loads the resourcesloader class which will load my resources (directory and file).

As to the file, I tried

JavaScript

in order to get the real path, but this way does not work.

I have no idea which path to use for the directory.

Advertisement

Answer

Supply the path relative to the classloader, not the class you’re getting the loader from. For instance:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement