User:Higgs1/Minecraft App Dir

For more information see the .minecraft page.

Java
The following code is 100% compatible. As in, this is exactly how the official minecraft client does it.

import java.io.File;

static final File getMinecraftWorkingDir { String home = System.getProperty("user.home", "."); String os = System.getProperty("os.name").toLowerCase; if (os.contains("solaris") || os.contains("sunos") 	   || os.contains("linux") || os.contains("unix")) return new File(home, ".minecraft/"); else if (os.contains("win")) { String appdata = System.getenv("APPDATA"); return new File(appdata != null ? appdata : home, ".minecraft/"); } else if (os.contains("mac")) return new File(home, "Library/Application Support/minecraft/"); return new File(home, "minecraft/"); }

Alternate Version
static final File getMinecraftWorkingDir2 { String home = (home = System.getenv("APPDATA")) == null ? System.getProperty("user.home", ".") : home; String os = System.getProperty("os.name").toLowerCase; if (os.contains("solaris") || os.contains("sunos") 	   || os.contains("linux") || os.contains("unix") 	    || os.contains("win")) return new File(home, ".minecraft/"); else if (os.contains("mac")) return new File(home, "Library/Application Support/minecraft/"); return new File(home, "minecraft/"); }