Question

I have an application which has a font stored within a jar file. It is loaded with:

public Font getChessFont()
{   

    InputStream in =  ClassLoader.getSystemClassLoader().getResourceAsStream("fonts\\MERIFONTNEW.TTF");
    Font toReturn;
    try
    {
        toReturn = Font.createFont(Font.TRUETYPE_FONT, in);
    } 
    catch (Exception e)
    {
        toReturn = gameInformation;
    }
    toReturn = toReturn.deriveFont(Font.PLAIN, squareSize);
    return toReturn;
}

When running the program from Eclipse or a jar file this code loads the font sucessfuly. However, after I put the jar files into an ISO image and mount them to a disk the files fail to load. Any ideas as to what I'm doing wrong?

Was it helpful?

Solution

Apparently my comment was enough to solve this. So the question can be "answered", I have added the comment as an answer:

Resource paths usually should use forward slash (/) in the path (more like a URL) as this is platform independent.

OTHER TIPS

Are the files/JARs on the disk on the classpath?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top