Pregunta

I have created a program to download a file and put it in a specific location but I cant get it to work on all systems. What could i change this to to make it work on all operating systems. /Users/anthonybuttillo/Library/Application Support/minecraft/mods/Enderized.zip

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top