Load resource file: relative to the class location
import java.io.IOException; import java.net.URL; public class Main { public static void main(String[] args) throws IOException { // relative to the class location URL url = Main.class.getResource("foo.txt"); } }