lunes, 30 de abril de 2012

NetBeans 7.1.2 Installation issues with OS X Lion

If you get trapped by the idea that Oracle just released it's new Java SDK 7 in a standalone installer with a "very easy to go" way of doing things, you might think twice! 


Due to changes in Apple management of Virtual Machines, they deprecated the path where the JVM's used to live, here the official note:


http://developer.apple.com/library/mac/#releasenotes/Java/JavaSnowLeopardUpdate3LeopardUpdate8RN/NewandNoteworthy/NewandNoteworthy.html#//apple_ref/doc/uid/TP40010380-CH4-SW1


Well, whatever, until now, hasn't been acknowledged by Oracle and the NetBeans team.
 Why? because I've just downloaded de package with the NetBeans bundle and the JDK installs ok but the NetBeans just throws a Install Failed message to the installer.


And that's it....


To debug this, I enter to /var/log/install.log and you can see the horror:

Apr 29 23:32:34 Davids-MacBook-Pro installd[3404]: ./postflight: + /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/bin/unpack200 ./apisupport/ant/nblib/org-netbeans-modules-apisupport-ant.jar.pack ./apisupport/ant/nblib/org-netbeans-modules-apisupport-ant.jar
Apr 29 23:32:34 Davids-MacBook-Pro installd[3404]: ./postflight: /Volumes/NetBeans 7.1.2/NetBeans 7.1.2.mpkg/Contents/Packages/baseide-201204101705.pkg/Contents/Resources/unpack200.sh: line 37: /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/bin/unpack200: No such file or directory
Apr 29 23:32:34 Davids-MacBook-Pro installd[3404]: PackageKit: Install Failed: Error Domain=PKInstallErrorDomain Code=112 "An error occurred while running scripts from the package “baseide-201204101705.pkg”." UserInfo=0x7ff7c0d04500 {NSFilePath=./postflight, NSURL=file://localhost/Volumes/NetBeans%207.1.2/NetBeans%207.1.2.mpkg/Contents/Packages/baseide-201204101705.pkg, PKInstallPackageIdentifier=org.netbeans.ide.baseide.201204101705, NSLocalizedDescription=An error occurred while running scripts from the package “baseide-201204101705.pkg”.} {
   NSFilePath = "./postflight";
   NSLocalizedDescription = "An error occurred while running scripts from the package \U201cbaseide-201204101705.pkg\U201d.";
   NSURL = "file://localhost/Volumes/NetBeans%207.1.2/NetBeans%207.1.2.mpkg/Contents/Packages/baseide-201204101705.pkg";
   PKInstallPackageIdentifier = "org.netbeans.ide.baseide.201204101705";
}
Apr 29 23:32:34 Davids-MacBook-Pro Installer[3396]: install:didFailWithError:Error Domain=PKInstallErrorDomain Code=112 "An error occurred while running scripts from the package “baseide-201204101705.pkg”." UserInfo=0x7fab2597e620 {NSFilePath=./postflight, NSURL=file://localhost/Volumes/NetBeans%207.1.2/NetBeans%207.1.2.mpkg/Contents/Packages/baseide-201204101705.pkg, PKInstallPackageIdentifier=org.netbeans.ide.baseide.201204101705, NSLocalizedDescription=An error occurred while running scripts from the package “baseide-201204101705.pkg”.}
Apr 29 23:32:35 Davids-MacBook-Pro Installer[3396]: Install failed: The Installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance.
Apr 29 23:32:35 Davids-MacBook-Pro Installer[3396]: IFDInstallController 259136F0 state = 7
Apr 29 23:32:35 Davids-MacBook-Pro Installer[3396]: Displaying 'Install Failed' UI.
Apr 29 23:32:35 Davids-MacBook-Pro Installer[3396]: 'Install Failed' UI displayed message:'The Installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance.'. 


Googling around didn't do much for me, so I decided to review the scripts and I found that postflight scripts made some references to the get_current_sdk.sh script, and there I found the failure. 


Here's the solution:
- For things to get smooth, first with Disk Utility convert the .dmg to a read/write
- Then mount the converted .dmg and seek for the get_current_sdk.sh in here
 /Volumes/NetBeans\ 7.1.2/NetBeans\ 7.1.2.mpkg/Contents/Packages/baseide-201204101705.pkg/Contents/Resources


- Open with the text editor of your preference
- On /Applications/Utilities open Java Preferences and order your preferred SDK, in my case I've already install Java 7
- Back to the get_current_sdk.sh, edit the default SDK with the one that matches your preferences, in my case it was the new sdk:


default_jdk="/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/"


-Save the file and run the installer once again, everything should run fine I hope!