Archive for the ‘Java’ Category

Oracle finally states its intentions regarding the future of NetBeans, GlassFish and VirtualBox

October 30, 2009

The Oracle acquisition of Sun Microsystems has generated a lot of excitement over the last months. It also generated a lot of uncertainty and fear about the future of some the popular open source projects sponsored heavily by Sun  – such as the great NetBeans IDE, the GlassFish Application Server and the VirtualBox virtualization software. I use all them to some extent in my day-to-day work, so I was very happy when I found this document, stating Oracle’s intention to keep supporting all those projects in the future.

So if you were curious to try any of them, but were holding back, because you were not certain if the projects will exist tomorrow – now is the time to give them a shot. I promise you, that you won’t be disappointed.

Mofidy JVM parameters for JBoss AS

September 3, 2009

Most people have been in a situation requiring them to change one or more of the parameters passed to the JVM on top of which JBoss AS is running. For instance – you may need a bigger heap, bigger perm gen size or something else. The best place to put these parameters is probably the following file:

$JBOSS_HOME/bin/run.conf

where $JBOSS_HOME refers to the directory in which you’ve unpacked the JBoss AS distribution.

Look for this section:

if [ "x$JAVA_OPTS" = "x" ]; then
JAVA_OPTS=”…”
fi

All you have to do now is adapt it to your needs.

Java type indicators in Eclipse

July 13, 2009

One of the things that I don’t like about the default Eclipse settings for Java
development is that in the package explorer all Java files appear in the
same manner(with the same icon). There is no visual distinction between abstract and concrete classes, enums, interfaces… Luckily for us Eclipse supports such a distinction and all you have to do is enable it.

Go to

Window -> Preferences -> General -> Appearance -> Label Decorations

and mark the check box saying “Java Type Indicator”. I’ve tested this on Eclipse 3.5 only, but I guess it is included in previous releases as well.

Eclipse, though not as feature rich as IntelliJ IDEA, offers a lot of features that one has to find for himself.

A switch on String idiom for Java

May 4, 2009

I’ve always been frustrated with the inability to write a switch on String in Java.  However the enum type introduced in Java 5.0 somewhat diminishes the issue. Read this excellent article on the subject.

The best way to implement the Singleton pattern in Java and Ruby

September 29, 2008

I haven’t posted anything lately, but I just received my brand new “Das Keyboard” and now I simply can’t stop typing. Recently I’ve been going through some effective technics to implement popular design patterns and I was surprised to see how few people where aware of them. For example since Java 5 the best way to implement the Singleton pattern is simply to use an enum like this:


public enum SomeClass {

INSTANCE;

}

This is possible due to the fact that in Java(unlike in C++ and C#) enums are full-blown classes(although they do not support features like inheritance for example). You get an added bonus when using an enum class – you do not have to worry about serialization – this is handled for you behind the scenes.

And this is how one should implement the Singleton pattern in Ruby:


require 'singleton'

class Some

  include Singleton

end

Through the magic of Ruby’s mix-ins you get a private constructor for your class and an ‘instance‘ method with which you can obtain a reference to the single instance of the class. And best of all – because this library has undergone a substantial degree of testing it is pretty much bulletproof. Things hardly get simpler than that.

Some presentations from JavaOne 2008

June 1, 2008

I found a couple of very interesting presentations from JavaOne 2008. Some of the topics discussed in them: UI trends – multi-device, rich, active, social, mashup – Ajax, jMaki, JSF (2.0), Server Push; Portal (2.0, JSR 286); Scripting languages (primarily Groovy), OSGi, NetBeans & Glassfish, JEE6, Java 7, the Business of Open Source.

Some valuable Maven 2 resources

May 6, 2008

If you are doing serious Java development you definitely need some serious build tool for your projects. In the past Ant was the only viable choice, but in the recent years Maven has become extremely popular as well. Granted Maven is far more than a build tool, it is used primarily as such. But despite all it’s cool features Maven has one great problem – it’s lack of decent documentation. There are however two freely available books that really help fill this void – “Better Builds with Maven” and “Maven: The Definitive Guide“. The first book is a little out of date, the second is currently not quite finished, but they can help you a lot, especially if you’re just getting started with Maven.