views:

45

answers:

2

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?

+1  A: 

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

matt b
+1  A: 

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.

Kevin Brock
After fixing this problem: http://dev.eclipse.org/newslists/news.eclipse.newcomer/msg01881.html and changing the slashes the program worked as expected.
Joshua