One more reason to like IntelliJ IDEA

So in my last post I complained about Eclipse developers’ unwillingness for fixing long standing bugs. Now less than a year ago, I suggested to JetBrains to add a feature to IDEA that can come in handy when you want to quickly setup a project:

Defining Libraries as Maven Coordinates

This enables developers to quickly define libraries as Maven coordinates even in projects that do not use Maven and then IDEA can download the appropriate JAR files for the project from Maven repos.

This can be done either by asking the developer to enter the dependencies in a text field like:

And also by providing a text field for entering additional repositories:

[or] Alternatively, a short form syntax might be used for declaring the coordinates:

Also there should be selectable options for downloading source and JavaDocs for the libraries from Maven as well.

And yes my friends! IDEA gurus do pay attention to their users’ requests. This feature has now been added to IntelliJ IDEA X, the next version of the IDE:

Getting External Libraries Easily

JARs of many frameworks and their dependencies get updated too often now. But you do not want to turn your project into a Maven project just because of this? Then this feature is just for you.

In IntelliJ IDEA 10 you can search for & download libraries with dependencies for any framework published on some public maven repository. Minimum Maven experience is required. Just click ‘Attach Classes from Repository…‘

Now let’s see when they will add my other feature request to IDEA: @SuppressWarnings like feature for HTML elements.

To be fair, the NetBeans team has also fixed all the bugs that I’ve reported to them very quickly. But, Eclipse… no matter how great you are and how great your architecture is, your WTP is sooo buggy and years after Maven’s debut, you still don’t have a rock solid Maven plugin. Shame on you mate!

Three tools for testing email sending using SMTP

Email1: smtp4dev: Windows 7/Vista/XP/2003/2010 compatible dummy SMTP server. Sits in the system tray and does not deliver the received messages. The received messages can be quickly viewed, saved and the source/structure inspected. Useful for testing/debugging software that generates email. I have been using this for quite some time now and it is working seamlessly.

2: MockSMTP.app: MockSMTP is a native Mac application that embeds its own SMTP server. It also features an e-mail client browser, enabling instant viewing of both raw content and HTML rendering, so you can see how your mail looks when delivered. A nice product overall but is buggy.

3: Dumbster: The Dumbster is a very simple fake SMTP server designed for unit and system testing applications that send email messages. It responds to all standard SMTP commands but does not deliver messages to the user. The messages are stored within the Dumbster for later extraction and verification. The best option among the three for unit testing Java applications.

MySQL, Foreign Keys, InnoDB, and ERROR 1005

For quite some time I had faced this mysterious problem with MySQL where it was refusing to create a new table in our application’s database with a foreign key relationship to one of its existing tables. The error message MySQL was displaying was not very helpful:
[cc]ERROR 1005 (HY000): Can’t create table ‘DB_NAME.TBL_NAME’ (errno: 150)[/cc]
[cci lang="sql"]SHOW INNODB STATUS[/cci] was not helpful either:
[cc lang="sql"]
LATEST FOREIGN KEY ERROR
————————
100716 1:27:25 Error in foreign key constraint of table DB_NAME/TBL_NAME:
foreign key (COL_NAME) references ANOTHER_TBL_NAME(ID_COL_NAME)) default charset=’UTF8′ engine=InnoDB:
Cannot find an index in the referenced table where the
referenced columns appear as the first columns, or column types
in the table and the referenced table do not match for constraint.
Note that the internal storage type of ENUM and SET changed in
tables created with >= InnoDB-4.1.12, and such columns in old tables
cannot be referenced by such columns in new tables.
See http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html
for correct foreign key definition.
[/cc]
Oddly enough MySQL had no problem creating two new tables with a foreign key relationship between them. Well, long story short, it turned out that the old tables were using latin1 charset whereas the default charset for my MySQL installation was UTF8 and also the columns that had a foreign key relationship between them were varchar columns*.

The solution was quite easy: explicitly setting the charset to latin1 in create table statements (or alternatively changing the default charset of the database to latin1).

*Use of VARCHARS should be avoided in primary key columns.

Programmer’s Drinking Song

Programmer’s Drinking Song (sung to the tune of “100 Bottles of Beer”)
99 little bugs in the code,
99 bugs in the code,
fix one bug, compile it again
101 little bugs in the code.
101 little bugs in the code…
(Repeat until BUGS = 0)

Well, this one was quite funny. Probably one more reason to write tests? Also, in Java and a number of other languages, Repeat until BUGS = 0 is just one little bug in the code ;-) .

JCP Specs should be published in ePub format too

With the ever increasing popularity of electronic book readers such as Amazon’s Kindle and Apple’s iPad, JCP should now publish all the Java specs in ePub format too. Unlike their PDF counterparts, ePub readers can render text with the user’s choice of font family and size. They also use the available display real-estate more efficiently.

In the near future ePub will be at least as important as PDF when it comes to electronic documents and books.

Simply send an email to the JCP PMO and let them know that you’d like the JCP specs to be published as ePub documents too.

Is Microsoft working on a version of .NET for OS X?

Looks like Steve Ballmer will be part of this year’s WWDC keynote presentation:

According to Trip Chowdhry, an analyst with tiny Global Equities Research, 7 minutes of Steve Jobs’ keynote is allotted for Microsoft. Microsoft will reportedly be talking about their development tool Visual Studio 2010. The new version of Visual Studio will reportedly allow developers to write native applications for the iPhone, iPad and Mac OS.

But could it be more than that? What if Microsoft announce that they are bringing .NET to OS X as well?

Fixing “Content Assist” for implicit objects of JSP pages in Eclipse

While Eclipse recognizes implicit objects in JSP pages, it fails to show the content assist popup for them. This can be fixed by adding the appropriate JSP/Servlet JAR files of your application to your project. If your target application server is Tomcat 6.0.x, for example, you can create a User Library and add the following Tomcat JAR files to it:

  • annotations-api.jar
  • el-api.jar
  • jasper-el.jar
  • jsp-api.jar
  • servlet-api.jar

And then add this User Library to your project. Now Content Assist should work for implicit objects as well. Alternatively, if your target application server is JBoss and you have JBoss Tools installed, you can select the J2EE 5.0 libraries from the Add Library… window to enable content assist for your Web app.