Jump to content

Read JSON file in .jar


Recommended Posts


I am developing a mod for Minecraft 1.16.5 and Forge, and in order to add a functionality, I need to retrieve some information from a json file located at this address: "\Mod Name\src\main\resources\data\modid\equivalencies\item_prices.json". During some tests in an auxiliary test class, which did not require the game to run, I successfully retrieved information from this file using a relative path (directly from the mod folder), but when I implemented this code in the actual mod code, I have a NoSuchFileException. I also have tried to use the relative path of that json file from the location of the actual class that will be using that file, but I still have the same exception.

So, I was wondering, where exactly is the starting point for the relative path to the json file, and how to find it? Or, even better, how to read that file the most efficiently?


Thank you in advance for your answers. PS: Sorry for my English...

Link to comment
Share on other sites

This topic is now closed to further replies.


  • Create New...

Important Information

By using this site, you agree to our Terms of Use.