1

So i have this code

File fontFile = new File("FrizQuadrataTT.ttf");;
FileInputStream in = new FileInputStream(f);
Font dFont = Font.createFont(Font.TRUETYPE_FONT, in);
Font f1 = dFont.deriveFont(15f);

Which import a font file called FrizQuadrataTT.ttf. I used to use Dr. Java to code and i recently started to use Eclipse but now in eclipse this code doesn't work. It does however work in Dr. Java.

Exception in thread "main" java.io.FileNotFoundException: FrizQuadrataTT.ttf (The system cannot find the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)

This is the error message that is given when run.

Exikle
  • 1,155
  • 2
  • 18
  • 42

1 Answers1

2

The file must be in your application's classpath. I believe that Eclipse will add the project's root directory to the classpath automatically, so you should just put FrizQuadrataTT.ttf directly into the project's root directory.

ecbrodie
  • 11,246
  • 21
  • 71
  • 120