If you’ve ever needed a static method to load a resource, there’s a lot of conflicting information about how to get a resource contained in your JAR. I tried SomeProg.class.getClassLoader() and a few others but ended up with either a null value or an exception. Eventually on a whim I tried the following, which worked.
The package is lime49.lockcrypt, and the file is located in the build path. As it happens I was loading a Chinese font.
InputStream in = LockCrypt.class.getClassLoader().getResourceAsStream("lime49/lockcrypt/fireflysung.ttf"); Font font = Font.createFont(Font.TRUETYPE_FONT, in);