Maven, the better quickstart

I read a lot of Maven documentation and at the end the most interesting question “How do I run an application with its dependencies?” wasn’t answered. Instead I was flooded with many xml configuration sections without showing a simple and complete configuration file. That’s why I wrote this howto but first a little story.

I came across Ivy and Maven a couple of days ago, both of which make it very easy to add a list of libraries to your Java project and add them to the classpath.

Basically both look for a project configuration file including your dependency list and they download the libraries from the internet and install them in the local repository ~/.ivy2 for Ivy and ~/.m2/repository for Maven which are then shared with your Ivy/Maven projects.

While Ivy is only a dependency manager which is integrated with the most popular build management system for Java projects (Ant), Maven is more than just such a manager. With Maven you have a build system and a dependency manager in one tool.

I focused on Maven and it took me a while to find out that a feature I was looking for wasn’t there natively. I assumed it would have a similar behaviour than Ivy but it hasn’t and works completely different.

I was missing a clear Maven howto which shows in 5 minutes how your project is created, compiled, packaged and especially how your standard java application is run afterwards.

I assume that Maven is already installed and that you are familiar with using a shell as I won’t use m2eclipse, the Maven integration for Eclipse. Maybe I’ll update this post later and give you a little introduction but for now let’s concentrate on using it in a shell.

I don’t guarantee that everything is 100% correct because I don’t use Maven that long. Post a comment if something is wrong.

Continue reading »

DeliciousDiggTechnorati FavoritesRedditLinkedInFacebookSpurlTwitterWebnewsYiGGMySpaceYahoo BookmarksFriendFeedGoogle BookmarksLiveJournalShare

There is no handler to execute for command

If you follow the Vogella tutorials, especially those about menu contribution, the error message There is no handler to execute for command might appear. They don’t mention that you have to take care about the return value of isHandled().

While I was experiencing the error message after the first time I hit the menu yesterday, I’m absolutely not able today to get the command run once. In fact the behaviour shouldn’t change over night but anyway keep an eye on isHandled.

My plugin output this today1:

11:21:23 zprototype.AbstractApplication::start   Starting the plugin
11:42:47 zprototype.command.LoadModel::addHandlerListener
11:42:47 zprototype.command.LoadModel::isEnabled
11:42:48 zprototype.command.LoadModel::isHandled
11:42:48 zprototype.command.LoadModel::isEnabled
11:42:48 zprototype.command.LoadModel::isEnabled
11:42:48 zprototype.command.LoadModel::execute
11:42:49 zprototype.command.LoadModel::isEnabled

AbstractApplication is actually the entry point of the plugin and LoadModel is the menu handler.

As you can see isHandled is executed before execute so if it returns false a NotHandledException will be thrown.

  1. I’m not sure if this output is alway the same as other developer did run the command once too before the message appeared.
DeliciousDiggTechnorati FavoritesRedditLinkedInFacebookSpurlTwitterWebnewsYiGGMySpaceYahoo BookmarksFriendFeedGoogle BookmarksLiveJournalShare