Reputation: 47
Firstly i'm 99% certain my path isn't wrong since it's the copied qualified path of the font file. I have no clue why java can't find the file, please help? Picture of the error code and my code to load up the font https://i.sstatic.net/2mMSz.png
Upvotes: 1
Views: 305
Reputation: 3171
The problem is likely that the 1game project isn't on the classpath for your Eclipse run configuration.
Since you're using Eclipse: Click on the little triangle next to the debug symbol or run circle. Then click on Debug Configurations/Run Configurations. Select the run configuration you've been using. Go to Classpath, select User Entries, and then click Advanced. Add folders, then select the root folder for your project (1game). Try running the run configuration again.
It should be noted that this is only a solution to get your code to run provided that the folder where the file in question exists will also exist at the same path after you've deployed your code. Since you've hard-coded the path in, I'm assuming this is the case. However, you might want to confirm. If the resources will be packaged in the jar with the rest of your code, you'll want to use Assets.class.getResourceAsStream
instead of a File
(Thanks to MadProgrammer for pointing this out).
Upvotes: 1