Linux: find the location of the executables

  • How to locate the binary, source and/or man page files for a command?
    $ whereis command

‘whereis’ has some options you can specify in order to limit the places to look at, or the type of files (binary, source, man page file, …etc).

The ‘whereis’ command returns all the places where the command can be found, looking into typical Unix locations. But, more frequently, you are just interested in finding where the commands you type on the command line are located on the filesystem, according to the $PATH variable.

  • How to show the path of a command?
    $ which command

Without parameter, it stops on the first command found in the path. If you want to list all the locations of the command in the path, you can call it with the -a option.

I encourage you to browse the man pages if you want a detailed description of these commands.

Posted in Tips and tricks | Tagged , , , , , | 1 Comment

Maven: check what it really executes

 

 

 

  • How to aggregate your pom?

Sometimes, the need arises to debug a pom file and then you want to have a clear idea of what Maven really executes. This command shows your pom file after the inheritance, profiles and variable substitutions have been applied.

    mvn help:effective-pom
  • How to aggregate your settings?

There is a similar command for the settings.xml file.

    mvn help:effective-settings
  • How to list the profiles that are activated?
    mvn help:active-profiles
    This command is particularly useful to check the profiles activated by default, when using the -P option, when using an environment variable, or any combination of these like in the following example:
    mvn -Denv_variable=value help:active-profiles -P profileToActivate
Posted in Tips and tricks | Tagged | Leave a comment

The Destructive Programming Manifesto

 

 

This is a repost of the original text in case it would disappear from Pen.io

The Destructive Programming Manifesto

We are programmers. We strive to write good code.
We acknowledge that efficient code is often locally unclear.
We cannot stand writing more comments than code to document our hacks. We would rather not have to fix code we wrote ages ago.
We are sick of trying to decipher code others wrote.

Hence, this is how we work:
We write code as small self-contained blocks with well-defined interfaces.
Sometimes, we use software techniques to enforce them.
When a block is inefficient or behaves incorrectly, we do not read its code.
We re-implement it. Because it’s faster. And because it gives us fewer headaches.

Posted in Humor, irony and sarcasm | Tagged , ,

Maven: sources and javadoc (…where available)

Maven Mug

 

 

 

  • How to display the dependencies in your project as a list?
  • mvn dependency:resolve

  • How to display the dependencies in your project as a tree?
  • mvn dependency:tree

  • How to download the source code for the dependencies in your pom?
  • mvn dependency:sources

  • How to download the javadoc for the dependencies in your pom?
  • mvn dependency:resolve -Dclassifier=javadoc -Dtype=jar

Posted in Tips and tricks | Tagged | Leave a comment

Book: ActiveMQ In Action

Book Cover of ActiveMQ In ActionI am, for many years, an active reader of the Manning serie called “in Action“. I probably bought half of the collection in printed edition. Not only because I’m pretty convinced some of them will become collectors (for example, the first version of “Struts in Action” for which I also own the accompanying T-Shirt) ;-), but also because I really enjoy the style of the collection and the way the chapters are structured. However, don’t believe I’m writing this review with a biaised opinion, because I have also been disappointed occasionally by some offsprings of the Manning family.

Please, note this review is based on one of the latests MEAP -Manning Early Access Program- edition offered in order to allow the avid readers to access the content of the book while it is being edited. This version should however be very similar to the printed edition.

Before we dive into the real content, let me introduce the authors. The book is written by three different persons, what in my opinion seems to be the maximum number of authors in order to ensure a consistent quality. However, in the case of “ActiveMQ In Action“, the CVs are pretty amazing:

  • Bruce Snyder is perhaps the most famous one of the three (at least I knew his name before reading his book ;-)). To name just a few things, he’s a member of the Apache Software Foundation and he works for SpringSource as Senior Engineer. He is also one of the developers for ActiveMQ. Additionally, he has already coauthored a few books: “Maven, the definitive guide“, “Beginning Spring framework 2” and “Professional Apache Geronimo“; and he has participated in the Expert Groups for JSR 243 “JDO 2.0“, JSR 221 “JDBC 4.0” and JSR 291 “Dynamic Component Support for Java SE“.
  • Dejan Bosanac is a Senior Software Engineer at FuseSource, a Progress Software company. He is an active committer on ActiveMQ, the author of “Scripting in Java: Languages, Frameworks, and Patterns” and he has also participated in the Expert Group for JSR 223 “Scripting for the Java Platform“.
  • Rob Davies is Chief Technology Officer at FuseSource. He is a founder of the Apache ActiveMQ, ServiceMix (Open Source ESB) and Camel projects. He has more than twenty years of experience in project management, software design and development with banking and telecom companies.

Now about the book! It is divided into four sections:

1. An introduction to Messaging and ActiveMQ that starts with a quick but very concrete overview of the subject (in the typical “In Action” style), and continues with a detailed explanation of the concepts of Message Oriented Middleware and JMS in order to lay down the necessary background knowledge.

The first chapter is a clear and concise quick start guide to ActiveMQ. It gives a high level picture of the subject, detailing the concepts of asynchronicity and of loose coupling and citing straightforward cases of usage. Then, it explains how to download, install and start it and how to run one of the examples provided with the MOM. I like the brevity of this chapter and how it goes directly to the subject: you can get a running ActiveMQ server in less than five minutes, at least if you already know a little bit about ANT. If you don’t know ANT, don’t worry: it’s not very difficult and basically you’ll just have to install it. This is probably the ultimate test to identify if you should be reading the book or not 😉

I remember I was feeling a bit disappointed when reading this chapter because I was expecting a JMS version of “Hello World” right at the start, and instead it was “just” the execution of a prebuilt example. But I’m too much used to the “In Action” books and browsing the second chapter I have realized that was coming soon.

The second chapter is a tutorial about JMS. It’s there just in case you have never used JMS before, or you haven’t used it for a long time. It’s a good refresher on the subject because it explains really a lot in just a few pages. However, don’t expect to find all in details: this is a book about ActiveMQ, not a book about JMS. You’ll find an explanation of the base principles (the types of jms messages, the jms domains: queueing and publish/subscribe), a description of the java classes and interfaces in the JMS specification, and an example of a simple application (the long awaited “hello world”) for each type of JMS domain. You won’t be a JMS expert after reading this chapter, but you will have all the ingredients in your hands to start using it and eventually become one.

The third chapter, that also closes the first section of the book, lays down the two example applications that will be used to introduce the many features of ActiveMQ through the rest of the book. These two examples are classical choices that are correctly balanced in difficulty and in openess to change; in order to be able to adapt to many usage scenarios. They are presented with sufficient details, including the download and installation of Maven, how to launch them and an extract of the expected results.

In this first section, I just regret not finding a quick comparison of ActiveMQ to a few other open-source solutions (RabbitMQ, OpenMQ, HornetQ…), or even non open-source ones (WebsphereMQ, SonicMQ, MuleMQ…). However I can understand this would have been a very difficult exercise. So maybe getting an overview of the features that make ActiveMQ a better choice in the crowd of JMS solutions would have been really nice instead. Next edition?

2. The second section dives you directly into the bowels of the beast with the exposition of the most important aspects of the MOM server: the connectors, the security and the options for the storage of messages.

The fourth chapter is about the configuration of the connectors, both the transport connectors used by the clients in order to connect to the message brokers, and the network connectors used in order to interconnect the broker servers. This chapter starts first with a presentation of the unified format of URLs used by ActiveMQ in order to configure and to reference the different types of connector. Then, after a brief overview of all the connectors, it goes into more details explaining for each one the pros and cons, when you should consider using it, and how to set it up (with a reference to the detailed documentation for the more advanced settings). This rather lengthy chapter is organized more like a reference material. I suggest, as the authors do, that you skip few subsections and come back when you actually need it. Just make sure you understand at least one example of connector in each category: transport and network.

Chapters 5 and 6 are very important for a good mastering of the subject.  With chapter 5, you really start to understand the power of ActiveMQ because it talks about the storage systems (for persistent and non-persistent messages), details the differences for queues and topics and exposes deeply the four different storage systems that you can use with ActiveMQ. It then focuses on the caching strategies that you can deploy in order to speed up the retrieval of messages.

Chapter 6 is about securing the destinations using simple or JAAS mechanisms (for authentication and authorization) going into the details of implementing JAAS login modules. Then it elaborates on message level authorization, on building a plugin in order to implement custom authentication and authorization, and on integration of ActiveMQ with certificates based security. This closes the second section.

3. The third section is more about the integration of ActiveMQ into you own environment.

Chapter 7 focuses on the integration in Java and Spring environments, explaining with great details the different strategies for embedding the broker in your Java applications and the various configuration options that are offered when you use it with Spring. This chapter is really polished, because it also includes the development of clients using Spring and it talks about the important topic of implementing the request-reply mechanisms using JMS.

Chapter 8 shows, with an example application, how to integrate with different servlet containers or application servers. It is demonstrated using Tomcat, Jetty, JBoss and Apache Geronimo. I regret there is not more examples with other application servers like Glassfish or Weblogic, but I suspect the goal of the authors was more to show the mechanism in details with various types of platform so you can help yourself after by searching a bit on the web if necessary. This would make sense because this chapter is probably going to be outdated very fast.

The next chapter is about the usage of ActiveMQ from other languages. The scripting languages are detailed first, with the usage of the STOMP protocol for Ruby, Python, PHP and Perl; .NET/C# and C++ are detailed next. Then the chapter cleverly elaborates on SOA and RESTful access to the broker for WebServices, and also on the access using Ajax.

4. The last section concerns the advanced usage of the broker in your entreprise. I won’t develop further here because of the diversity and complexity of the topics covered. But -to name just a few subjects- this section covers clustering, scaling and load balancing, high availability, network and storage topologies, multicasting, logging, monitoring and statistics, administration of the broker, usage of wildcard and multiple destinations, system notifications and the virtual messaging, …the list continues and it is really long.

Conclusion

The overall writing quality is excellent. The text is very comprehensive. This is an important point for me as I am not a native english speaker and I don’t always manage to find a lot of time to read. I could however spot a few (actually, very few) typos, but nothing serious. The style is direct and concise and the subject is treated very seriously. Though I would have appreciated to find a few funny quotes, because I feel they help to relax a bit while reading and so help to memorize better. But this is more of a personal taste, maybe not shared with everyone who could rather see this as a distraction.

In conclusion, a must read book for anyone interested into the subject.


Posted in Reviews | Tagged , , , , , , , | Leave a comment

How to replicate an Eclipse update site for offline usage?

EclipseToday I’d like to share with you an Eclipse tip that I found a few months ago when browsing for an issue in the m2Eclipse Jira. The credit goes to Rich Seddon.

Sometimes you need to install an Eclipse plugin without an access to the Internet or -perhaps more frequently- with an (extremly stupid) firewall that blocks the traffic and prevents the download (and additionally destroys your productivity as developer by pretending all the technical subjects are related to hacking :p)

Unfortunately, the website for this plugin doesn’t offer a zip file in order to install it offline. And your network administrator -who doesn’t want to understand anything in development- has all the power (you’re completly out of luck, maybe you should consider another company rather than be reading this :-)).

So, here is what you can do in order to create a mirror of the update website, from another computer that has Eclipse installed and that has access to the net:

/eclipse -application org.eclipse.update.core.standaloneUpdate -command mirror -from http://www.aniceplugin.com/update-site -to /path/to/local/directory

The various commands for the update manager are further detailed in the Eclipse documentation under the section “Running update manager from command line”.

Posted in Tips and tricks | Tagged , , | Leave a comment

Smartphone, the geek attitude

When I was a young student, the coolest guy was naturally the one who had the most success with the girls. And at that time, because I had some computers knowledge, I was regularly seen as a geek. Things have changed a bit now, but at that time in particular, that was quite the opposite of “being cool”.

Nowadays the coolest guy seems to be the one who has the best smartphone application. So, even if I’m married with a family and I don’t have the opportunity to play yet, I fully understand why the youngsters use all the opportunities to take it out 😉

And above all, I really appreciate how “being geek” became the same as “being cool”.

Posted in Humor, irony and sarcasm | Tagged , , | Leave a comment