Launch Minecraft from command line - username and password as prefix

mort picture mort · Jan 26, 2013 · Viewed 111.2k times · Source

I'm trying to make a simple custom Minecraft launcher thing.

According to the Minecraft Wiki page for the Launcher, it should be possible to run the Minecraft launcher using username and password prefixes from the command line and go directly to the game instead of through the launcher.

I've tried various versions of java -cp -u=username -p=password minecraft.jar net.minecraft.LauncherFrame, and what it says is the old method:

java -cp minecraft.jar net.minecraft.LauncherFrame <username> <password>

The old method opens the minecraft launcher, just as if I double clicked the jar file, however it does not go directly to the menu screen.

The new way (using password and username as prefix), gives me an error message saying the prefix -u=username or -p=password don't exist.

Any help on this? I'm really stuck.

Answer

Drew DeVault picture Drew DeVault · Mar 22, 2013

You can do this, you just need to circumvent the launcher.

In %appdata%\.minecraft\bin (or ~/.minecraft/bin on unixy systems), there is a minecraft.jar file. This is the actual game - the launcher runs this.

Invoke it like so:

java -Xms512m -Xmx1g -Djava.library.path=natives/ -cp "minecraft.jar;lwjgl.jar;lwjgl_util.jar" net.minecraft.client.Minecraft <username> <sessionID>

Set the working directory to .minecraft/bin.

To get the session ID, POST (request this page):

https://login.minecraft.net?user=<username>&password=<password>&version=13

You'll get a response like this:

1343825972000:deprecated:SirCmpwn:7ae9007b9909de05ea58e94199a33b30c310c69c:dba0c48e1c584963b9e93a038a66bb98

The fourth field is the session ID. More details here. Read those details, this answer is outdated

Here's an example of logging in to minecraft.net in C#, and an example of launching minecraft.jar.