October 27, 2010

The Default Timeout Value for Standard Java Socket is Infinitive!

In my last week I have been doing some stability testing using both the Java standard java.net.Socket and javax.net.ssl.Socket. Which are both are part of the J2SE standard library. What I found out to my big surprise, was the standard value for socket timeout (getSOTimeout()) is infinitive!

What are the consequences of this? Well, except that all blocking socket operation will hang forever. But maybe the biggest problem is, it opens up for Denial of Service (DoS) problems.

Example DoS: A server is overloaded and services it's request slower and slower. And now, if new additional clients connected, even more resources are consumed. What will happen with this system in the end is it will ran out of memory or IO. This is not wanted!

What is wanted is a fail-fast strategy, i.e. client that do not get response in a certain time will close it Socket and report back to interactive user or machine.

October 24, 2010

Ubuntu 10.04 Change Default Size of Terminal

One of the probably first thing you want to change when starting using Ubuntu is to change the default size of the Terminal window. In earlier version of Ubuntu that could be accomplished via the Edit -> Profile Preference menu from the Terminal, but with Ubuntu 10.04 that is no longer possible. Instead do the following:

Go to System -> Preferences -> Preferred Applications -> System (tab)

Change Terminal Emulator to "Custom".
Command: gnome-terminal --geometry=237x24
Execution flag: -x

October 8, 2010

JAOO Day 4 – Not Only SQL, NOSQL

Today I listened to Emil Eifrem CTO at Neo Technology. What I liked most of his talk was the categorization of the today existing NOSQL solution:

Key-Value Database
An Amazons project that uses global key-value mapping to for DB.

Dynamo: Amazon's Highly Available Key-value Store (2007) (http://s3.amazonaws.com/AllThingsDistributed/sosp/amazon-dynamo-sosp2007.pdf).

Other Example:

Column Database
A Google project that uses a big table, with column families.

BigTable: A Distributed Storage System for Structured
 Data (2006) (http://labs.google.com/papers/bigtable.html)

Other Example:

Document Database
Data is organized as document and a document is a key-value pair.


Graph Database
Data is organized in a graph, which Nodes and Relationships have properties.


Example of company using NOSQL
  • Google: Bigtable
  • Amazon: Dynamo
  • Amazon: SimpleDB
  • Yahoo: HBase
  • Microsoft: Dynomite
  • Facebook: Cassandra
  • LinkedIn: Voldemort 

October 7, 2010

JAOO Day 4 – Java Future at Oracle

Today I was listening at Brian Goetz in his talk “Java Future at Oracle”. This talk was a warn welcome, since yesterday Java User Group, where it was not so much warmth about the evolving of the Java language, due to the problem in the Java Community Process (JCP). And how this has set footprint in the deliveries of new JDK version.

JDK 1.0 1996
JDK 1.1 1997
JDK 1.2 1998
JDK 1.3 2000
JDK 1.4 2002
JDK 5.0 2004
JDK 6.0 2006

JDK 7.0 2011?
JDK 8.0 ???

So what about new feature, well he said that they going to push out JDK 7.0, but of the expense of cutting functionality, which means in short:

And that's it.

But on the other hand he also said that JDK 8.0 will be planned to be released thereafter 1-2 years, which sounds promising. Which Project Lambda (http://openjdk.java.net/projects/lambda/) will among other stuff be included. Other stuff in the pipe is also the Project Jigsaw (http://openjdk.java.net/projects/jigsaw/).

But the most interesting stuff was the news that they plan to merge the HotSpot with the JRockit! Wow, what a killer that will be! But, an unanswered question is, if they will change the license model of the JDK. It is like Brian put it: Oracle is really an easy company to understand, it is about making money.

And what about the JCP? Well, he quickly mentioned the problem, and this a top priority for Oracle to solve. And I really do hope that they solve this and quickly.

October 5, 2010

JAOO Day 3. The Stagnation of the Java Language

Today I visited one of Java User Group (JUG) at the JAOO conference – the “Next next step for the Java ecosystem.” There were three person in panel James Gosling, Kevlin Henney and Dave Thomas and they all three confirmed on the misfortune fact that the Java Community Process (JCP) is not working properly or as Rod Johnson (member of JCP board) put it in his session “Where Next for Enterprise Java”. Compare the number of Java Specification Request (JSR) produced this year with the number produced 2-3 years back.

And one can really ask when JDK 7 will be released and how much really will be included of the project Coin (minor language feature change), Jigsaw (effort to make Java more modular) and Lambda (bring closure to Java)?!?

And I guess this fact is the why there today are so many new language created for the JVM – the community is responding and will not wait.

But there is rescue to the help and as James put it, if you cannot wait use Scala.

James Gosling

Kevlin Henney

Dave Thomas

Rod Johnson

Getting Started with Scala - IDE support

The key thing when start using a new library or as in this blog, start writing a completely new language, is to have an IDE that is working with and not against you.

I had the pleasure of talking with both Martin Odersky and Jonas Bonér at JAOO in Aarhus Denmark and they both recommended the IntelliJ Scala plugin, but Martin also added that he had started a company scalasolutions.com with one of the aim to write a better Scala plugin for Eclipse, and when that comes out, I would really recommend you to test it. Another question which IDE to choose is also of course which IDE you have previously worked with and acquainted with.

In this blog I will share my experience of using both the IntelliJ and Eclipse IDE, but also how to build your Scala code with Maven.

Since I don't have a business license of IntelliJ I used the Community edition, you can find the comparison matrix between the free and commercial edition and also the download link from.

After installing IntelliJ, you install the Scala plugin with the Plugin Manager

File | Settings | Plugins

Select tab Available and search for Scala, then right click to install.

After restarting, you create a new Java Module and add Scala Library from local downloaded Scala distro.

  • Normal code completion and code navigation works.
  • OBS when debugging, you have to append the name mangling '$1' to every variable to be able to Evaluate. This seems a bug in the Plugin, since the name mangling should be shielded from you and is strict Scala internal, to overcome Java restriction of operating overloading, etc.
  • The IntelliJ Scala plugin compiler is really slow, even for small amount of code. There are ways to get around this by using Scala background compiler server, but I have not got that up and running yet.

I used the Eclipse 3.5.2 (Galileo) and install the Eclipse Scala plugin (http://www.scala-ide.org/) with the Eclipse built in Software Installation.

Help | Install New Software... | http://download.scala-ide.org/update-current Add

After that you can create a new Scala Eclipse Project.

  • The Scala Plugin compiles code enormous time faster compared with the IntelliJ, but it also have drawbacks.
  • Code completion is not always working if program Scala in it most compact form, sometime it then helps to program a little more verbose, e.g. anonymous function "kalOk".exists(char => char.isUpperCase) instead of the more compact "kalOk".exists(_.isUpperCase)
  • OBS when debugging, you have to append the name mangling '$1' to every variable to be able to Evaluate. This seems a bug in the Plugin, since the name mangling should be shielded from you and is strict Scala internal, to overcome Java restriction of operating overloading, etc.
  • Code completion is not always working.

After testing both IDE, I must say that Eclipse wins, and mostly because of the slow compilation in IntelliJ. But I hope even if you choose to use another IDE, that this blog post helped you with choosing which IDE you will use.

After choosen IDE, you clearly also want to have build tool support and I will here discuss Maven, but I also knew that SBT (http://code.google.com/p/simple-build-tool/) is also a great alternative, but I will not cover that in this blog.

The simplest way is to use the scala archetype, but before please check the page http://docs.codehaus.org/display/MAVENUSER/Archetypes+List, to see that not a newer version has been released.

To check that everything worked install the new Maven project.

Now lets open the new pom and see what has been generated. The first thing you see is that Scala 2.7.0 is used, change that to 2.8.0 but also remove the Scala Spec Test in


Finally you can also remove the specs dependency. I will in coming post discuss Scala Unit Testing, but for now simply use JUnit 4, that you are probably familiar with.

Thats it happy coding!

Day 2 at JAOO. A Compact Day with James Gosling, Jim Webber and GIT

Day 2 was a packed day with big stars as James Gosling and for you that don't know it, Gosling have quited Oracle, if you want to read more, google or read Gosling own blog http://nighthacks.com/roller/jag/.

But the day started with Cliff Click from Azul Systems (azulsystems.com) and talked about top ten performance problem they seen of hosted Java application in production. This was interesting and I will probably get back with a better blog about that. What also was interesting was suggested tools for detecting different kind of problem:


  • dtrace, hprof, introscope, jconsole, visual vm yourkit


  • dtrace, oprofile


  • Ganglia, iostat, lsof, nagios and netstat

The next talk was from Google about Scalability, Availability and Stability, which in mine humble opinion, brought not so much new solution to the problems. It all cooked down to sharding, fanning out,  replication vs. caching, eventual consistency and asynchronous calling.

After lunch did Jim Webber talked. Jim Webber is mainly the guy behing REST and if you are intrested about that you should definitely read his book. REST in Practise.

At the end of evening I had the pleasure of talking to both Martin Odersky and Jonas Bonér about the new started company Scala Solution (http://www.scalasolutions.com/) IDE plugns, faster compile time, who is owning the code, founding and Scala akka (http://akkasource.org/), but I will get back more about that later.

October 3, 2010

Day 1 at JAOO Object-Orienteed meets functional: An Overview of Scala

The first Training at JAOO 2010 was held by Martin Odersky in Scala. Scala is truly an interesting new programming language, it runs on top of the JVM, but brings so much new programming technique that is not possible with the existing Java language.

It was a truly refreshing talk, but also a sadly realization that the evolution of the Java language has really slowed down since the release of Java 5. The difference between Java 6 and Java 5 is mostly a faster JVM, that is not bad, but on the functional side of new language technique is quite depressing to see such a short list of new feature. And it is not getting better. A couple of days ago a checked out the Oracle web page of new programmatic feature in Java 7 one can see the list is short.

And what is happening the other main stream programming corner at Microsoft? Well they have not been lazy. On could right fairly argue that C# has been become a more advance language than Java. So with this in mind, I'm really looking forward to participate the Training. So what did Martin talk about. Well, the Scala language is really huge, so the talk for 4 hours, did not covered all parts, but one thing is sure. Looking at Scala is almost like learning a new language. For you out there, that have not started looking at Scala I only got one question for you:

Do you want to program Java 6 or 10? See the complete video of Martin Odersky. http://www.scala-lang.org/node/1305

"If I were to pick a language to use today other than Java, it would be Scala"
by James Gosling, creator of Java

"I can honestly say if someone had shown me the Programming in Scala book by by Martin Odersky, Lex Spoon & Bill Venners back in 2003 I’d probably have never created Groovy."
by James Strachan, creator of Groovy

"Scala, it must be stated, is the current heir apparent to the Java throne. No other language on the JVM seems as capable of being a "replacement for Java" as Scala, and the momentum behind Scala is now unquestionable. While Scala is not a dynamic language, it has many of the characteristics of popular dynamic languages, through its rich and flexible type system, its sparse and clean syntax, and its marriage of functional and object paradigms."
Charles Nutter, creator of JRuby