0

I have looked in numerous places for the answer to this question and yet to find something that works. I have a project in eclipse set up like so (I hope you can understand it):

(Project)
src/package1/class1.cs
src/package2/class2.cs
JRE_SYSTEM_FILES/
res/font.ttf

So inside of the "res" folder, I have a font.ttf. I understand how to add the font to my program and use it using Font.createFont(), but What I cant understand is how to get the file path. Everything I find assumes I have the path already which I don't. If anyone can help that would be greatly appreciated, and please If my formatting gets in the way of understanding the question please tell me.

mKorbel
  • 109,525
  • 20
  • 134
  • 319
matt murray
  • 233
  • 2
  • 12
  • read Oracle tutorial about PAckaging in Java, but the logics is same as for evergreen here - [Image](http://stackoverflow.com/a/9866659/714968) by @nIcE cOw – mKorbel Dec 17 '13 at 19:14

1 Answers1

0
  1. use relative paths, run from the same place every time

  2. put font to the same folder where your class (that requires it) is, and call getClass().getResource("font.ttf");.

Sergey Fedorov
  • 2,169
  • 1
  • 15
  • 26
  • Okay, I'll do that, but in more in-depth programs where single resources are used multiple times, how would I acccesss a resource in a folder outside of the source folder? – matt murray Dec 17 '13 at 17:37
  • You don't need to keep resources in 'src' folder. You only need to know relation between class file that needs font and font location. Say, you have font.ttf in classes/fonts and class that needs it in classes/package1. Then, call `getResource("../fonts/font.ttf")`. – Sergey Fedorov Dec 17 '13 at 17:46