Archive for the 'Java' Category

Google IO: GWT

I many 10-5 developers not working directly with ajaxified web 2.0 applications I was not able to go to the Google I/O conference. I don’t feel so bad not going since Google has just released video recordings of over 70+ technical presentations from Google I/0. Most of the technical presentations are pushing Google’s APIs such as Android, Google App Engine, GWT, and Open Social.

As an aid for myself, and maybe other GWT developers, I have organized the pertinent GWT presentations as follows…

Surprisingly Rockin’ JavaScript and DOM Programming in GWT
You may already know about GWT’s nifty JavaScript Native Interface (JSNI), which allows you to define native Java methods with handwritten JavaScript. In GWT 1.5, there’s an even more powerful way to program close to the metal. You can now model arbitrary JavaScript types directly as Java classes (specifically, as subclasses of GWT’s JavaScriptObject class), yet there is no overhead in size or speed. You can code against any JavaScript object as if it were a regular old Java object. So, what does that buy you?


Read more »

Google IO: Open Social

I many 10-5 developers not working directly with ajaxified web 2.0 applications I was not able to go to the Google I/O conference. I don’t feel so bad not going since Google has just released video recordings of over 70+ technical presentations from Google I/0. Most of the technical presentations are pushing Google’s APIs such as Android, Google App Engine, GWT, and Open Social.

As an aid for myself, and maybe other Open Social developers, I have organized the pertinent Open Social presentations as follows…

Meet the OpenSocial Containers
Representatives from current OpenSocial containers give an overview of their implementations, policies, and what’s unique about their container. They also share some of the fruits of their labors including high level stats. Team members from upcoming containers review their planned launches, policies, and timelines.


Read more »

Google IO: Android

I many 10-5 developers not working directly with ajaxified web 2.0 applications I was not able to go to the Google I/O conference. I don’t feel so bad not going since Google has just released video recordings of over 70+ technical presentations from Google I/0. Most of the technical presentations are pushing Google’s APIs such as Android, Google App Engine, GWT, and Open Social.

As an aid for myself, and maybe other Android developers, I have organized the pertinent Android presentations as follows…

An Introduction to Android
Android is the Open Handset Alliance’s mobile software platform. Come learn about Android and our vision for more open, powerful, and useful mobile devices.


Read more »

Java 6 and JDBC 4.0

I just migrated a 4,000+ Java class project from Java 1.4.2 to Java 6. I’ve already mentioned some of the issues to be aware of when migrating a large code base to Java 6. In Java 6, enum is a reserved keyword so I had to renaming variables that had that name, I also had to upgrade to a more recent version of Apache Commons Lang for a similar reason. I also had minor issues compilation issues, such as the removal of compareTo(Object obj) method was removed from the String class, and Apache classes that once shipped with the JRE 1.4.2 where removed.

But what irked me the most about Java 6 was recent changes to JDBC 4.0. The ResultSet interface, in Java 6, has 197 methods that need be be implemented if you are working with custom ResultSet implementation. I am just shocked at the sheer number of methods required for a basic ResultSet, most of which are not used, or will ever be used by our custom implementation! This is what is wrong with Java. The good thing is that Eclipse auto code generation features saved me from typing all of those methods but I wished there was a basic ‘do nothing’ abstract adapter like WindowAdapter.

Technorati Tags: , , , , , ,

Introduction to Classes and Objects

I often get asked to explain the difference between a Java class and an object. A common way to describe a Java class is to think of it as a blueprint, cookie cutter, or factory used to create objects with. A class defines the implementation details, the fields and methods to store the state and execute the behavior of objects. In contrast, an object is an instance of a class. There can be one or many object instances for a given class but there is only one class for a given type. A common example of object state is that when you have an ArrayList, the list has a size. The ArrayList also has a certain behavior, to increase by one element and update the list size, when you invoke the add method. The size and contents are the state of an ArrayList, and adding and removing elements is its behavior.

In addition to declaring and implementing the fields and methods, state and behavior, for a object, a class can also define methods that don’t logically belong to a single object instance but that belong to the class type itself. Methods that belong to the class are marked as static. A common example of static methods are those in the Math class. You can’t create a object instance of the Math class, the default constructor is private. Since you can’t instantiate an object, all the methods it declares are invoked at the class level. To invoke the absolute static method made available in the Math class you do so by the following example.

Here is how you would access the static PI field in the Math class.

Technorati Tags: , , , , , ,

Class Loading Error

The Java language specification dictates that static fields and blocks are initialized the first time a class is loaded, from top to bottom. So my coworker was utterly dismayed when a static hash map in a certain class was getting a new object instance each time he requested an instance of said class. At first I was taken back by the problem as he described it, I thought maybe the object was serialized or marshaled, maybe it was programmer’s error and he had set a new map to the static field in some other setter method, then I remembered that this piece of code uses a new URLClassLoader instance each time it tries to load this particular class. This new class loader was used because we load this class dynamically at runtime as a external plugin. To fix this bug we just keep and used the same class loader instance each time we loaded this plugin class.

Class loaders are fun but this is one example of how if used incorrectly can lead to interesting behavior. These are the type of bugs that reminds me of those Java Puzzlers.

Technorati Tags: , , , , , ,

Next Page »