Minecraft Wiki
Advertisement

Random Code

I hereby release all of my rights to the following code.

Finding .minecraft (Java)

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/");
}
Advertisement