Jdk 7 and NullpointerException

NullPointerException is one of the most common exception encountered in Java programming. This proves how pervasive the exception is and how much effort a developer has to put in writing java code free from null pointer exception.

Suppose we have a method to fetch postal code of a person’s address:

public String getPostcode(Person person) {
	if (person != null) {
		Address address = person.getAddress();
		if (address != null) {
			return address.getPostcode();
		}
	}
	return null;
}

Now check the above syntax. We have done lots of if (null != object) checks to avoid NullPointerException.

Java 7 (Codename: Dolphine) will change the way we do Null handling in our code. Java 7 will be released in first half of 2010. If we write above code using Java 7 Null-safe Type (also called Null-ignore invocation), it will look like:

public String getPostcode(Person person) {
	return person?.getAddress()?.getPostcode();
}

That is a great way to reduce the lines of code Java programmers are used to write to do Null checks.

Published in:  on October 28, 2009 at 4:14 am Leave a Comment
Tags:

365 Days, 4646 Kilometers walk across China

In November of 2007, 33 year old soul-seeker, Christoph Rehage, decided to walk from Beijing to Germany. He didn’t make it all the way, but he did cover 4646km on foot between Beijing and Ürümqi without touching a scissor or razor his entire trip.

Check out the stop motion chronicle of his journey.

Long walk of the soul seeker

Long walk of the soul seeker - Christoph Rehage

The Longest Way 1.0 – one year walk/beard grow time lapse from Christoph Rehage on Vimeo.

Published in:  on August 25, 2009 at 5:56 am Leave a Comment

GTUG at GooglePlex

At GooglePlex

Aug 9 2009 : At the GooglePlex at Google, One of the world’s best campus to work at. Free wifi to go around with your laptop, all over the campus. I have got many acknowledgements here to support the excitement. Google Technology User Group meetup started on Aug 7 2009 went on for 2 nights and today is the third day. Here are some really enthusiastic coders at work. I myself slept very less this weekend, but there are people who slept for less than 3 hours. Tents were scattered outside on the lawn, where coders camped. Coders who were determined to build applications over the weekend. I wish I could do something like building a small wave application. We did start out well on Friday night to build an automated Groupy bot. The learning of the new apis and the setup took a while, the interest was well invested. There were some clear tutorials to try out on Google Wave robots.

But as we started building we realized , what we wanted to achieve turned out to be an advanced feature. There were no apis to support it yet. Nevertheless , it was a time well spent. Made new friends, learnt how to write a robot. Had a Google experience. Got interviewed by Mercury news, made it to the siliconvalley.com : Silicon Valley news

Here is the site from GTUG , Mountain View : http://sites.google.com/site/svgtugcampout

Published in:  on August 21, 2009 at 5:49 am Leave a Comment

Tag Cloud generator

Just found this site tag cloud generator. Nice cloud generator , if you want to add it to your site. Below is the html cloud. There is an option to get a flash based cloud.
Published in:  on August 20, 2009 at 6:04 am Leave a Comment
Tags:

Android UI : Make it fast and efficient

On July 14, SF Java User Group organized another great meetup. The speaker was Romain Guy from Google’s Android team. Apparently good photographers transcend into good UI coders Romain Guy’s site . The presentation (from Google I/O Conf.) provides the tips and tricks about how to create faster UI using Views, backgrounds, rescaling Images for faster rendering, better use of Views and Layouts.  Here is the presentation – How to make Andoid UI efficient ?

Some of the questions from the Q&A session included:

Q: Will Android support languages other than Java?
A: Romain mentioned that there is a version of Scala and python that work on Android, but currently all APIs are in Java.

Q: Does Flash work on Android?
A: Development is on-going and the Android team is working with Adobe.
(There is a nice article on Gizmodo : Flash for android webos landing in October)

Q: Can JavaFX be used on Android?
A: Code might be hard to run on the phone and may not be performant.

Q: Apparently, Sony Ericsson are also building an Android phone. How do you plan to avoid fragmentation as other companies start shipping Android phones?
A: CTS – Compatibility Test Suite
You can’t ship a phone as ‘Android’ if it doesn’t pass the CTS.

Other links you would want to go thru :
http://d.andriod.com
source.android.com
android.git.kernel.org
code.google.com/p/apps-for-andriod
http://android-developers.blogspot.com/
http://forum.xda-developers.com/

If you are using Eclipse and wanto set up android plugin , check this out :

If you have trouble viewing the video plugin site is : https://dl-ssl.google.com/android/eclipse/


Once you set it up you can use the emulator Android Emulator to test the apps.

Here is the entire video of the talk :

By the way the next version of Android is called “DONUT”, Guess what the version next to that is called ?

Published in:  on July 22, 2009 at 3:56 am Comments (1)
Tags: , ,

Spring-EJB3 integration

spring

meets EJB3

On June 9, 2009 SF Java User Group organized a session with Reza Rahman to discuss about Spring and EJB3 Integration solutions. EJB 3 and Spring are often cast as contenders. However there are a growing number of applications that combine the strengths of both these technologies to create compelling best-of-breed solutions.

Here is the presentation slides from the talk and demo examples.

Spring-EJB3 Integration presentation from Reza Rehman

demo.zip

The examples are really simple , try it out  ;-)

Published in:  on June 25, 2009 at 4:39 am Leave a Comment
Tags: , , , ,

Install Ubuntu on Sun’s xVM VirtualBox

This video from “midfingr” is a very nice demo of installing Ubuntu Linux on Sun’s Virtual Box. If you are running vista and want to run Linux, this a good option.

If you do not find the VBOXADDITIONS. Restart Ubuntu after the part 1 of the install. Devices > Install Guest Additions…. You should be able to mount the VBoxGuestAdditions.iso.

Here are the install steps for Ubuntu 9.04 :
Install Ubuntu 9.04

Enjoy the freedom of Open source !

Published in:  on May 7, 2009 at 7:57 am Leave a Comment
Tags: , , , ,

Flex as seen through Java’s eyes

                       fx_icon_special_100x100

                                              duke-thinking1

On April 14th, the San Francisco Java User’s group had their monthly meetup at Google, San Francisco. Walt Schlender , a Flex enthusiast and Chet Haase, Flex scientist from Adobe gave a great presentation on Adobe Flex and introduction to ActionScript3 from a Java developer’s perspective. As a Flex noob, this talk has raised my general interest in AS3 and Rich Internet Applications in general. I would like to highlight some features in Adobe’s Client side platform Flex from the presentation, in comparison with Java.
Variable declaration in -

            Java : private String s = “Java”;

            Flex : private var s:String = “Java”; (by the way semicolon is optional in Flex! So your compiler does not moan at the missing semicolon any more)

Function declaration in -

            Java : public boolean sampleFunc(String s){ …. }

            Flex : public function sampleFunc(s:String):Boolean { …. }

Packages in -

            Java :

                package foo;
                class FooThing {
                     .........
                }

             In Flex , the package has enclosing brackets over the entire package body :

                package foo{
		    class FooThing {
                      .........
		     }
                }
  • Flex has a concept of undefined for variables which is not present in Java, but Undefined != null. AS3 has “undefined”, “null”, and “NaN” concepts.
  • Java has final has the keyword final, but Flex has “const” instead of “final” ( That makes it easier to remember). And Flex does not have private or protected constructors, all of them are public.
  • At the compiler level, Java compiles just the source code into the binaries. But in Flex, the source code along with the Flex libraries used by the source code are both compiled.

I will leave the detailed article to explain more about the differences. It is worthwhile read for an introduction to ActionScript3.

duke-chalkboard1
JavaWorld Presentation on AS3 Part 1

JavaWorld Presentation on AS3 Part 2

Overall Flex is Adobe’s trump card in the RIA game. The RIA apps you can build with Flex is FTW ! Check this Online dice application Walt Schlender has written, it is nice one. It has the simple source code in the presentation, which is easy to try. If you do not have Flex , here is  60 day free Flex trial.

Java has been the most extensively used language for back-end / enterprise applications. Adobe Flex enables developers to create highly interactive interfaces for web and desktop applications. A marriage between the two technologies means a lot to the Software world.

Java EE and Flex: A compelling combination

One most important question that nobody liked to answer was , Is JavaFx better than Flex ? 

Tom, jerry and Spike

On one of the San Francisco sidewalks, life goes like this too …

Tom, Jerry and Spike

Tom, Jerry and Spike

 

 

... and the guy who doped them all :)

... and the guy who doped them all :)

Published in:  on March 25, 2009 at 4:05 am Leave a Comment
Tags: , ,

An evening with a Yogi

On the third Friday of this March, the Isha foundation organized a speech with “Sadhguru” at Herbst theatre on Van Ness. I got an entry without having to stand in the wait lines , thanks to my roomie who put a “+1″ when he RSVP’ed.  The theatre was filled with the international audience. It is always nice to see people from different countries get together for a spritual discourse, when it is all terrorism and economic chaos around the world. It started with a musical performance and a dance. The marketing face of the foundation propped up with a flashy handout and a presentation on being a Non Profit Organization. A lady who was influenced by this guru said her association with Sadhguru change her life , she had a book for sale about her experience.

The Sadhguru walked up with all humility and took his seat on the stage , all other sounds faded away. He started the talk with a shloka. I liked some of his starters , here is one “What if you and an owl sat together and had a discussion, is day better or a night ? If you say both are good, then you have a happy married life”. He went on with a soothing speech, interspersed with meditation.The subtle topics of mind, body and soul are always nice to hear from a yogi. It was 2 hours of my Friday spent well, I felt refreshed. 

 

Sadhguru jaggi vasudev

Sadhguru jaggi vasudev

 

Here is a video from one of his speeches : 

 

Published in:  on March 21, 2009 at 8:57 pm Comments (2)
Tags: , , , ,