28 June 2010

Installing NetBeans 6.9 Fails when XCode is Running

I've been trying to install the NetBeans 6.9 official release (netbeans-6.9-ml-java-macosx.dmg) but it kept on failing during the "Preparing Installation" phase.  No detailed errors were shown other than a generic statement to contact my software vendor.

Turned out, at least on my MacBook  Pro, that the cause seemed to be that XCode was running at the same time.  As soon as I quit from XCode and ran the NetBeans installer from the same installation package, it worked without any problems and installed NetBeans successfully.

Don't know if this is isolated to NetBeans or more generally to the installer technology used on the Mac, but it seems that there was some contention with Xcode, which resulted in the installer not working.


24 June 2010

Dynamically Setting JAVA_HOME on Mac OS X

This was a new discovery to me today, so please ignore if this is widely used and known.

On Mac OS X, there is a very specific, managed directory structure for the various Java versions that are installed.  The general directory is "/System/Library/Frameworks/JavaVM.framework/".  For those of us new to Mac OS X, the sub-directories under there look a little foreign.

To run WLS, you need to set JAVA_HOME to the appropriate directory before you can start a domain.  Hardcoding the directory into either .bashrc or the startWebLogic.sh scripts does the trick.

But today I stumbled on another little utility that can be used to dynamically determine the current  JAVA_HOME, as set in the user preferences:

       java_home - return a value for $JAVA_HOME

       /usr/libexec/java_home [options]

       The  java_home  command  returns  a path suitable for setting the JAVA_HOME environment variable.  It
       determines this path from the user's preferred Java in the Java Preferences application.   Additional
       constraints may be provided to filter the list of JVMs available.  By default, if no constrants match
       the available list of JVMs, the default order is used.  The path is printed to standard output.

Thus setting JAVA_HOME dynamically in scripts, shell profiles can be done simply like this:

export JAVA_HOME=`/usr/libexec/java_home`

21 June 2010

NetBeans 6.9 Released

I've been using NetBeans 6.8 quite a bit lately to explore new functionality in Java EE 6.

Just noticed on the weekend (somewhat belatedly) that their latest 6.9 version has been finalized and released.  At a measly 178mb for the core IDE with Java EE 6 support and an embedded GlassFish v3.0.1 server for the dev/test runtime, it sounds like a download well worth making.

04 June 2010

Running WLS on Mac OS X with Correct Memory Settings

The shell scripts that launch WLS on Mac OS X don't seem to set the JAVA_VENDOR to Apple, which means that the relevant USER_MEM_ARGS are not specified when the server is started.

To remedy this I've been setting JAVA_VENDOR="Apple" before starting my domain.

But occasionally I forget.  So to automate the setting, I udpated $DOMAIN_DIR/bin/setDomainEnv.sh as follows:

if [ "${JAVA_VENDOR}" = "Oracle" ] ; then
    export JAVA_HOME
    if [ "${JAVA_VENDOR}" = "Sun" ] ; then
        export JAVA_HOME
        if [ "`uname`" = "Darwin" ] ; then
            export JAVA_VENDOR

            export JAVA_HOME

This then results in the relevant MEM_ARGS for Apple being set later in the script:

if [ "${JAVA_VENDOR}" = "Apple" ] ; then
    export MEM_ARGS
Now starting the domain on Mac OS X, the necessary memory arguments are set on the JVM and the server runs as expected.

$ startWebLogic.sh
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02-279-10M3065)
Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01-279, mixed mode)
Starting WLS with line:
/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/bin/java -client   -Xms512m -Xmx512m -XX:MaxPermSize=128m -Dweblogic.Name=myserver ...