Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

19 May 2011

First Adelaide Java User Group Session @ Oracle

Tonight sees the first time that the Adelaide Java User Group meeting is being hosted @ the local Oracle office.  

The session should be interesting with Derek Webber presenting on his area of expertise in Meta-programming with Groovy.

Meta-programming with Groovy

Meta-programming is a term to describe modifying code at runtime and is a very old idea in Computer Science. Groovy (now at 1.8) is a language that builds features directly on top of Java and aims to help developers be more productive. It’s meta-programming features provide a great number of opportunities to developers that are either really difficult to access or are all but impossible in plain Java. I will provide an overview of the Groovy Meta Object Protocol, along examples of what you can do with it. In particular it helps with:
  • easier reflection and adding behaviour dynamically
  • monkeypatching and extending existing 3rd party code
  • builders and domain-specific languages (DSLs)
For any local Adelaide folks interested in attending, the registration link is here: 
http://www.jugevents.org/jugevents/event/registration.form?event.id=38181

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:

NAME
       java_home - return a value for $JAVA_HOME

SYNOPSIS
       /usr/libexec/java_home [options]

DESCRIPTION
       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`