How to get Java/Scala system environment variables and properties

Want to get the system environment variables and/or properties from your Scala or Java application? This quick post shows what environment variables and properties are available.

Here’s a little Scala application that prints all the environment variables and properties. You’ll see that you can convert it to Java very easily:

Scala: Reassignable variables and properties (def fields)

Sadly, I had to get away from Scala for a while, but now I can get back to it again. Just as I started getting back into it I happened upon the following code, and thought, “Well, surely title in this anonymous class is a var field. How strange that the Programming in Scala guys would use a var like this.”:

Scala: How to define properties in an abstract base class or trait

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 4.13, “How to define properties in an abstract base class or trait.”


You want to define abstract or concrete properties in an abstract base class (or trait) that can be referenced in all child classes.

Setting a Scala application's command line parameters in Eclipse

I’ve been developing a new Scala application named Cato that requires some command-line parameters, and I just had to figure out how to configure Eclipse so my application would get those parameters. Doing this with Scala in Eclipse is different than configuring Java command line parameters in Eclipse, so I thought I’d share the recipe.

Fortunately it’s just a two-step process. First, click the drop-down icon next to the “Run” button and choose “Run Configurations”, as shown here:

How to read/access Play Framework application.conf properties

Here’s a quick look at how to read Play Framework application.conf configuration properties.

First, given a Play application.conf file with these properties:



stations = [ 99.5, 102.3, 104.3, 105.9 ]

streams = [
    { "name": "104.3", "file": "104_3.pls" },
    { "name": "WGN",   "file": "wgn.pls" }

You can read the foo property (as a String) from your Play code like this:

The Chrome JavaScript debug console and [Object object]

As I’ve gotten back into client-side web development -- specifically using Sencha Touch 2, a JavaScript framework -- I’ve quickly run into a problem in the Chrome JavaScript debug console. When I try to use console.debug() to debug an object, I get this non-useful output about the JavaScript object I’m printing:

[Object object]

There may be better ways to print the desired object, but I quickly discovered this trick to printing all of the properties of a JavaScript object:

Scala SBT - How to force/require a specific SBT version

I ran across this code snippet in the SBT docs, and thought it was a good but hard to find tip. To force/require a specific SBT version in a Scala/SBT project, include a line like the following in a file named in your project/ subdirectory:

sbt.version = 0.11.3

So, if your project directory is named /Users/Al/Foo, the file would be here: