The issue in this specific case (a Minecraft mod) is relatively simple because the place where a Minecraft installation resides is standardized. As can be read here the Minecraft installation folder is
- Windows Vista/7: C:\Users\YourUserName\AppData\Roaming\.minecraft
- Windows XP: C:\Documents and Settings\YourUserName\Application Data\.minecraft (note - both Windows variations can be found through the
APPDATA
environment variable) - Linux: /home/Your User Name/.minecraft
- Mac OS/X: ~/Library/Application Support/minecraft
So, just detect the OS and starting from the user's home directory ( String s1 = System.getProperty("user.home", ".");
in Java ) you can build the required path.