I have a Java desktop application that downloads tens to hundreds of MB of image and music data as part of its normal operation. It maintains a disk cache of this data. If part or all of the cache is removed, the app will notice and re-download the missing data.
This is a 20-year-old app and historically it has placed the data in a hidden (~/.myapp) directory under user.home
. I'm planning an update, and I'm wondering if there are canonical locations for storing application cache data for Windows, MacOS and Linux, and if so, if there are standard ways of accessing those paths from Java.
The only precedents I'm aware of are Gradle and IntelliJ, both desktop Java apps. Gradle does what my app does currently; it creates a ~/.gradle directory and dumps data there. IntelliJ apparently tries to use more canonical paths as of the 2020 edition; e.g., on Macs it saves cache data to ~/Library/Application Support/JetBrains/<product><version>
.
Is there a library that will provide me with the canonical location my app cache on each OS? If not, does someone have a list somewhere so I can create the directories in the right places manually?