Thursday, November 24, 2011

Minecraft on Mac OS X with 64-bit Java

So you're a slave to warning messages and you want Minecraft to use 64-bit Java.  Here's how to do it on the command line.  These instructions were crafted on MacOS Lion, which should prefer 64-bit Java when possible (Applications/Utilities/Java Preferences).  These instructions assume the default Minecraft.app location, in the main /Applications folder.  I had a few tabs open, while I was sussing this out, including an excellent forum post, a post on JavaApplicationStub bits, and the official reference for CF keys.

Here we go.

Swap out Minecraft's JavaApplicationStub for the current OS' version:
  gzip /Applications/Minecraft.app/Contents/MacOS/JavaApplicationStub
  cp /System/Library/Frameworks/JavaVM.framework/Versions/Current/Resources/MacOS/JavaApplicationStub /Applications/Minecraft.app/Contents/MacOS/

Then, add 64-bit architecture to Minecraft's possibilities:
  /usr/libexec/PlistBuddy -c "Add :Java:JVMArchs:0 string 'x86_64'" /Applications/Minecraft.app/Contents/Info.plist

Launch.  That should do it.  Watch out for creepers.  Have a nice day.


* * *


If everything goes wrong, here's how to roll back from here to your original configuration:
  rm /Applications/Minecraft.app/Contents/MacOS/JavaApplicationStub
  gunzip /Applications/Minecraft.app/Contents/MacOS/JavaApplicationStub.gz
  /usr/libexec/PlistBuddy -c "Delete :Java:JVMArchs:0" /Applications/Minecraft.app/Contents/Info.plist


How to tell if you're using a 64-bit kernel in the first place is easy.  Look for "x86_84" in the output of the below command.  If you see i386 or ppc, you might be on a system that can't handle 64-bit, or you might need to instruct the system to boot with a 64-bit kernel.
  uname -a   # should include "x86_64" in the output.


What's this JavaApplicationStub anyways?  It's like a chain loader .. only different!  When you double-click the Minecraft icon, the Finder looks in Info.plist for the CFBundleExecutable value.  It launches that, to start the app.  The JavaApplicationStub is a native binary that helps invoke Java in the right way to get Minecraft running.

What's that PlistBuddy command?  It's a command-line tool included in more recent releases of Mac OS, that lets you directly read, write, erase, fold, spindle and mutilate Plist.info files.  It's got a man page, but here's a quick example of reading your JVMArchs array, if you want to double-check that it's got x86_64 at the top:
  /usr/libexec/PlistBuddy -c "Print :Java:JVMArchs" /Applications/Minecraft.app/Contents/Info.plist

What's with you and the command line stuff?  I don't know.  I suspect that my epitaph will simply be an elegant one-liner.

4 comments:

  1. A couple of points:
    • Changing the stub shouldn’t be necessary. I did this a while back, and my loader was downloaded several months ago and didn’t need it changed.
    • Whether you’re using a 64-bit kernel is irrelevant. OS X had 64-bit userland support well before the 64-bit kernel, and since Snow Leopard it’s been the norm regardless of which kernel you’re using.

    ReplyDelete
  2. Thanks for the detailed information. and also most of the times both 32 bit and 64 bit works as these expect in some cases where if there are any machine specific calls are called. 32 bit takes 4 bytes long,64 bit takes 8 bytes of size, so 32 bit takes less size compared to 64 bit machines.
    To find out the 32 bit or 64 bit 32 bit or 64 bit

    ReplyDelete
  3. The Post seems to be good i really gather lot of information from the post thanks for sharing this awesome post minecraft hosting

    ReplyDelete