gary on June 21st, 2009

http://developer.yahoo.net/blogs/hadoop/2009/06/yahoo_distribution_of_hadoop.html

Bookmark and Share

It’s easy to use and update the git version of Configgy and other code hosted at github. If you don’t have git, you can use MacPorts to install it:

$ sudo port install git

Then clone the Configgy repository with

$ git clone git://github.com/robey/configgy.git

Then cd into the top-level directory and build as described below.

When you want to update, just pull the latest changes and rebuild.

$ git pull
$ ant clean; ant package

Note that ant package may be particular to Configgy. Sometimes just ant is sufficient and will use the defaults.


Bookmark and Share

Tags: ,

gary on June 21st, 2009

Configgy is a great configuration and logging library for Scala. You can read info/examples on the release page or git the current repository.

To install, just download and, in its directory, type

$ant package

( The ‘$’ is your terminal command-line prompt. Don’t type it.)

If you see the following errors:

[scalac] Compiling 16 source files to /Users/Gary/Development/scala/configgy/target/classes
[scalac] /Users/Gary/Development/scala/configgy/src/main/scala/net/lag/configgy/JMXWrapper.scala:51: error: wrong number of arguments for constructor MBeanInfo: (java.lang.String,java.lang.String,Array[javax.management.MBeanAttributeInfo],Array[javax.management.MBeanConstructorInfo],Array[javax.management.MBeanOperationInfo],Array[javax.management.MBeanNotificationInfo])javax.management.MBeanInfo
[scalac] new jmx.MBeanInfo(”net.lag.configgy.ConfigMap”, “configuration node”, node.asJmxAttributes(),
[scalac] ^
[scalac] /Users/Gary/Development/scala/configgy/src/main/scala/net/lag/configgy/JMXWrapper.scala:115: error: value asList is not a member of javax.management.AttributeList
[scalac] for (attr <- jcl.Buffer(attrs.asList)) setAttribute(attr)
[scalac] ^
[scalac] two errors found

…it’s because Configgy requires Java 1.6. You probably haven’t set your JAVA_HOME and are defaulting to Java 1.5. To correct your environment variables on the Mac, see my notes below.

Next, if you’re trying out the example code and see an error like:

Compiling 1 source file to /Users/Gary/Development/NetBeansProjects/ScalaApplication1/build/classes
/Users/Gary/Development/NetBeansProjects/ScalaApplication1/src/scalaapplication1/Main.scala:27: error: value get is not a member of net.lag.configgy.Config
val hostname = config.get(”hostname”, “localhost”)

…it’s because that function has been renamed getString(), but not all of the documentation has been updated. Change it to:

val hostname = config.getString(”hostname”, “localhost”)


Bookmark and Share

Tags:

Nice talk about alternatives to shared-state concurrency on the JVM. Notice the gradual acceptance by the community that shared-state concurrency is too hard to get right and must be abandoned. Alternatives are being sought; this talk discusses STM, Actors, and Dataflow. I also hear more death knells for Java. Due to the required language integration of concurrency paradigms, new languages are needed such as, in this talk, Clojure and Scala. (The Actor example is Scala, as is the Dataflow example.)

http://www.slideshare.net/jboner/state-youre-doing-it-wrong-javaone-2009


Bookmark and Share

Tags:

gary on June 21st, 2009

When working with Java and Scala, you might have to set environment variables. For example, compiling the excellent Configgy for Scala requires Java 1.6. How do you set the environment variables so that Scala programs compile with Java 1.6? It’s easy, but there are some gotchas.

Currently (June 2009), the Mac OS (10.5.7) defaults to Java 1.5. You can change this setting using the Java Preferences program in /Applications/Utilities. Drag 1.6 to the top of the list. Run “java -version” from a command line to see which version the system will use. You should go ahead and switch it to use the latest Java, but you’re not done yet.

The Java Preferences panel affects which version of Java is run, but not which JDK is used. For development, you need the correct Java JDK. Set it via JAVA_HOME.

A simple and oft-recommended way to set JAVA_HOME on the Mac is to point it to “/Library/Java/Home/”. However, this location is for the system’s default, which is currently 1.5.

You want to use 1.6, so point to it directly at

/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home

If you follow that path, you’ll see that there’s also a 1.6.0 directory. But selecting 1.6 means that it will point to the latest 1.6.x version. Use 1.6.0 if you need to specify 1.6.0 specifically.

Now, where to set that variable… Common advice is to set it using a shell export such as

export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home

Add that line to your ~/.profile or your ~/.bashrc and you’re done. That will certainly work for any terminal compiling that you do. But it won’t work for programs installed in your /Applications folder that you don’t run from the command line.


To get those applications to ’see’ the environment variable, use the Doug McClure’s free program RCEnvironment. It’s a System Preferences pane that will edit ~/.MacOSX/environment.plist for you. You could just edit the file, but it’s XML, so let RCEnvironment balance the tags for you.

Finally, if you’re using an ant-based build, you can easily see which sdk is being used in the build process by running

$ ant -diagnostics

…and reading the through the output.


Bookmark and Share
gary on June 17th, 2009

The Scala Eclipse plugin is in development, so we can forgive little issues. One I keep running into is that programs sometimes can’t find themselves upon start. On the canonical hello-world program, I see:

Exception in thread “main” java.lang.NoClassDefFoundError: HelloWorld
Caused by: java.lang.ClassNotFoundException: HelloWorld

So far, the only explanation I’ve found from searching the web is that the metadata is horked, so the workspace must be nuked from orbit, that being the only way to be sure. I’ve tried it and it works, but this approach is hardly practical for production coding.


Bookmark and Share

Tags: ,

gary on June 17th, 2009

For completeness, here’s the manual Scala installation. It’s also quite simple:

1. Download Scala from http://www.scala-lang.org/downloads, picking the IzPack Installer
2. Run the Installer: java -jar scala-2.7.5.final-installer.jar

I haven’t tried it, as I use the MacPorts method described below. MacPorts automates the switching of paths to new versions, updates, removals, etc in a consistent way for many software packages, reducing developer cognitive load.


Bookmark and Share
gary on June 17th, 2009

MacPorts is an easy way to install and manage Scala on the Mac. Once MacPorts is installed, you can install Scala using:

sudo port install scala

Sudo will ask for your password. Wait. Done.

Once installed, you may want to know where it was installed. For example, you may need to set the SCALA_HOME environment variable. Just do

port location scala

To update your Scala installation, just do

sudo port upgrade scala

Note that after I upgraded, the location command tracks the old one, even though the new one is active:

$ port location scala
The following versions of scala are currently installed:
scala 2.7.3_0
scala 2.7.4_0 (active)
Error: port location failed: Registry error: Please specify the full version as recorded in the port registry.

So just use ‘@’ to specify the version:

$ port location scala @2.7.4_0
Port scala 2.7.4_0 is installed as an image in:
/opt/local/var/macports/software/scala/2.7.4_0


Bookmark and Share

Tags:

gary on June 14th, 2009

Facebook’s Notes application can import blogs, but the links shown in wall updates link to the Notes instead of your blog. Lame.


Bookmark and Share
gary on June 14th, 2009

When you have to make an effort to unify this many moving parts, that should smell like a business opportunity. For example, walk around a Web 2.0 type conference and count how many companies are building ‘turn-key’ ’solutions’ on top of cloud computing infrastructure.


Bookmark and Share