Get the location from the execution location of the Java code

I have a swing Java application that can save a lot of data (for example, you can consider games and their saving) The data is stored in a file instead of a database

I want to save these files near the installation file (. Jar file) of my application Some users (such as me) delete the default application folder of the operating system. When it becomes larger, I don't want them to lose their data

How can any idea easily do this? How to start from executing Jar file Jar file folder? Or how to export files directly to a package? How to dynamically create packages (folders in jars)? Or there is a simple way to distribute Java applications in other formats and then Jar and then store the generated data in the installation (sub) folder?

Thank you for reading

resolvent

Solution

This (and the concept of a multi-user system with no write access to the application directory for regular user accounts) is why user data should be stored in the user's home directory, not anywhere near the application installation folder

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>