The Holy Java

Building the right thing, building it right, fast

Posts Tagged ‘eclipse’

Tip: How to Easily Customize PMD Rules in Eclipse

Posted by Jakub Holý on August 21, 2012

The default PMD rules are little too strict for me (especially when starting on a legacy project) so I need to adjust them, usually by decreasing priority to warning. It’s however quite difficult to find the rule responsible for an error message unless you know how to do it. The answer is the PMD Violations Overview view, which lists the rule names (such as “ConstructorCallsOverridableMethod”, as opposed to the error message such as “Overridable method ‘addSummaryPeriod’ called during object construction”).

Read the rest of this entry »

Posted in eclipse, Tools | Tagged: , | 1 Comment »

Most interesting links of December

Posted by Jakub Holý on December 31, 2011

Recommended Readings

  • The Netflix Chaos Monkey – how to test your preparedness for dealing with a system failure so that you won’t experience nasty wakeup when something really fails in Sunday 3 am? Release a wild, armed monkey into your datacenter. Watch carefuly what happens as it randoly kills your instances. This is exactly what Netflix does with their with their cloud infrastructure – also a great inspiration for my recent project. Do you need to be always available? Than consider employing the chaos monkey – or a whole army of monkeys!
    (PS: There is also a post with a picture of the scary monky.)

Links to Keep

  • BDD: Write specifications, not scripts (from the Concordion site) – relatively brief yet very enriching practical description of how to do behavior-driven development a.k.a. Specification by Example right, the key point here being “Write specifications, not scripts.” It says why not (for scripts overspecify -> are brittle, specs should be stable) and how to do it (decouple the stable spec and the volatile system via fixture code, expose minimal stuff to the spec, perhaps evolve a DSL between the fixture and the system). It also lists common “smells” of BDD done wrong. If it still isn’t clear to you, read the Script to Specification Makeover example (or perhaps read it anyway). BTW, Concordion is a new tool for doing BDD based on JUnit and HTML, which was created as a response to the weaknesses of Fit[Nesse], i.e. exactly the tendency to do scripting instead of specifications. It looks very promissing to me!

SW Utilities

  • (Linux/Mac) Autojump – superfast navigation between favorite directories in the command line (via Jake McCrary) – it keeps track of how much time you spend in each directory and when you execute j <substring of directory path/name>, it jumps into the most frequently used one matching the substring. It awesome! (You can also run jumpstat to see the statistics.)
  • (Linux) Tcpkill – service/network outage testing (via Jake McCrary) – kill connections to or from a particular host, network, port, or combination of all – useful e.g. when you want to test that your software is resilient to the outage of a particular service or server – less brutal than actually killing the database etc. instances. We need to test that our application recoveres properly when one of our MongoDB nodes dies so this may be quite useful.
  • Manik Hot Deploy Plugin for Maven Projects (v1.0.2 in 5/2011; older version in the Marketplace) – plugin that can do hot and incremental deployment to any app server (simply by copying to its hotdeploy directory or the directory of an installed webapp) whenever you run mvn install or automatically whenever sources change, multi-module support

Clojure Corner

  • Jake McCrary: Continuous Testing With Clojure and Expectations – continuous test runner lein-autoexpect for Clojure tests written using the library expectations by Jay Field.
  • Jake McCrary: Quickly Starting a Powerful Clojure REPL – Clojure REPL only two steps away: 1) Run Emacs, 2) Execute M-x clojure-swank (no more need to open an existing Leinigen project) – the trick is to install the Leinigen plugin swank-clojure and use Jake’s elisp function clojure-swank that automatically starts the swank-clojure server. (I had to hack the function for the clojure-swank output contained “null” instead of “localhost”, likely due to incorrect DNS setup.)

Posted in eclipse, General, Testing, Top links of month | Tagged: , , , , , , , | Comments Off on Most interesting links of December

Comparison of Eclipse 3.6 and IntelliJ IDEA 10.5: Pros and Cons

Posted by Jakub Holý on October 18, 2011

After having worked with Eclipse for over 5 years I’ve came to use IntelliJ IDEA intensively on a J2EE project in three months and took this as an opportunity to compare the two. You can’t really compare 5 years and 3 months but I still believe that it is long enough to get a pretty good overview of what a tool is like.

For the impatient:

IntelliJ is a very good tool, its killing feature for me is its excellent support for other languages such as Groovy (e.g. for unit tests) and Clojure. Many details are more worked-out and with a higher usability then in Eclipse, f.ex. search & replace with match highlighting and replacement preview. Its support for navigability and refactoring across multiple languages (Java, JSP, JSF, HQL, Spring config in my case) is also an absolutely great feature for productivity. And of course I have to add it credits for being a Czech product [1] (interestingly enough, NetBeans also comes from the Czech Republic [2]; it’s a pity Eclipse hasn’t this link too) :-).

My main issue with IntelliJ is its performance. First, running tests is slow because IntelliJ only does (re)compile the test/source when you hit the run button as opposed to Eclipse’ incremental compilation. And that makes TDD very painful. (I tried to use the old Eclipse Mode plugin but it has problems with IntelliJ 9/10.) Second, sometimes the UI freezes* and you have to wait seconds or tens of seconds for it to respond again (even after disabling most plugins and some analysis). It doesn’t happen too often but often enough to be noticed, to be annoying, and to interrupt the development flow.

*) Update: UI freezes may be a specific issue of Mac 64b 1.6 JDK

So I guess I’ll use either Eclipse or IntelliJ with respect to the needs of the project at hand and hope for IntelliJ to resolve its performance issues (as NetBeans did). Read the rest of this entry »

Posted in eclipse, Languages, Tools | Tagged: , , | Comments Off on Comparison of Eclipse 3.6 and IntelliJ IDEA 10.5: Pros and Cons

Introduction to ObjectTeams/Java, a Role-Based Approach to Modularity With AOP

Posted by Jakub Holý on March 27, 2011

I’ve recently stumbled upon an interesting Eclipse project called ObjectTeams/Java (OT/J), which promises improved reusability and maintenance and support for evolvable architectures by creating well-encapsulated bundles of behavior – modules – that can be applied to existing classes (via AOP), when they are in the appropriate context of interaction (and not simply always, as is the case with AOP). An example application is the addition of NonNull constraint to JDT via an OT/Equinox plugin, without the necessity to modify JDT’s base classes. I’ve decided to write down my discoveries as the project is missing a clear and brief introduction (though it has otherwise very good documentation). This blog borrows heavily from [1]. Read the rest of this entry »

Posted in Languages, Tools | Tagged: , , , | Comments Off on Introduction to ObjectTeams/Java, a Role-Based Approach to Modularity With AOP

Creating dynamic EMF model from XSDs and loading its instances from XML as SDOs

Posted by Jakub Holý on January 3, 2011

This post describes how to read a dynamic EMF model from a set of XML schema files (XSDs) and how to use that model to transform XMLs to SDO DataObjects or EMF EObjects, all this in a stand-alone environment. Read the rest of this entry »

Posted in Languages | Tagged: , , , , , , | Comments Off on Creating dynamic EMF model from XSDs and loading its instances from XML as SDOs

EMF: Reading a model from XML – how to correctly declare its namespace – variants

Posted by Jakub Holý on January 3, 2011

When you use the Eclipse Modeling Framework (EMF) to read a model instance from an XML file, such as a webservice call message payload, it’s essential for EMF to be able to match the root XML element with the model’s “ePackage” that should be used for (re)constructing the model instance from the XML and this is done by matching the root element’s and the ePackage’s namespaces (as in XSD). So it’s very important to have proper configuration of EMF and proper content of the XML. Since there ale multiple variations of both, there are more ways to get it wrong than right. To learn what I’ve discovered regarding the valid combinations suitable at different situations, read on. Read the rest of this entry »

Posted in Languages | Tagged: , , , | 5 Comments »

More Eclipse & svn fun: Can’t share a project (only Team – Apply Patch)

Posted by Jakub Holý on November 23, 2010

With Subversive it may happen that it completely ignores some projects while it perfectly works for other ones. If a project seems to have no SVN information in Eclipse (thoug it actually contains all the .svn/ folders) and the Team context manu only contains Apply Patch… (i.e. especially not Share project…) then you have likely mixed up Eclipse metadata about the project (for instance by sharing it previously with Subclipse).

This is a well known problem and the solution is to Delete the project (without deleting its content) and to re-import it into Eclipse. Also make sure that the Subversive back-end version supports the version of Subversion (too many *versions here :)) recorded in the project metadata. If needed, you can use a script to up/down-grade the SVN metadata, as described in a FAQ.

Posted in eclipse, Tools | Tagged: , , | Comments Off on More Eclipse & svn fun: Can’t share a project (only Team – Apply Patch)

Tip: Enable a shortcut for Occurrences in File in Eclipse under Gnome (default C+S+u)

Posted by Jakub Holý on November 2, 2010

The useful Eclipse action Search – Occurrences in File – Identifier has by default the shortcut Control+Shift+U. But under Gnome the shortcut Control+Shift+U is used for Unicode character input, indicated by an underlined u when pressed. Assigning a different shortcut is easy but there are few “traps”:

  1. In Eclipse, go to Window – Preferences – General – Keys
  2. Type the filter occurr and click on “Shows the Occurrences in File Quick Menu“. Do not confuse it with “Occurences in File” (binding C+S+A, when Editing in Structured T. Ed.)!
    1. Make sure that When is “In Windows“, Category is “Search
    2. Click [Unbind Command], click into the Binding field and type the keys that you want. Beware that some keys could conflict with existing bindings or global Gnome/system bindings. For me e.g. Control+Shift+S or F8 worked (though I might have to unbind conflicting bindings, I don’t remember anymore).

Environment: Eclipse 3.5, Gnome 2.30.2, Ubuntu 10.04.

Posted in eclipse, Tools | Tagged: , | Comments Off on Tip: Enable a shortcut for Occurrences in File in Eclipse under Gnome (default C+S+u)

Most interesting links of August

Posted by Jakub Holý on August 31, 2010

I hope everybody is enjoying the holiday and not spending hours on tech blogs and sites. At least I do :-) and thus this month’s list is a short one:

  • Working With Static Imports in Eclipse – how to make working with static imports (nearly) as easy as with the normal ones (especially useful for fluent interfaces and “DSLs”), mainly by adding types like JUnit’s Assert and Mockito to your favorite imports and setting Eclipse to always generate static imports in the form <type>.*
  • 5 things you didn’t know about … Java Database Connectivity – it was interesting to learn that JDBC specifies some scalar functions that drivers may support and translate into the DB’s language such as “{CURRENT_DATE()}”; for common functions supported by most drivers this should make your implementation more portable
  • Four Things to Remember about java.lang.String – a really good one thanks to information on how to compare correctly the same Unicode character/string that can be encoded in different ways with java.text.Normalizer.normalize and Locale-sensitive comparison ignoring optionally unimportant differences such as letter size and accents (using a Collator)

Posted in Languages, Tools, Top links of month | Tagged: , , , | Comments Off on Most interesting links of August

Eclipse Profile configuration: The launch requires at least one data collector

Posted by Jakub Holý on May 13, 2010

I just installed TPTP into my Eclipse 3.5 under Ubuntu 9.04 and tried to profile a class. The Profile Configuration opened with a red warning reading “the launch requires at least one data collector to be selected“. Clicking the configuration’s Monitor tab reveals a more detailed error (and nothing to select):

IWATO435E An error occured when connecting to the host.

A quick check of the error log (Window – Show View – Other… – General – Error Log) reveals the cause:

RAServer generated the following output:  [Error Stream]:ACServer: error while loading shared libraries: /home/jholy/development/tools/eclipse-ide/pulse2-2.4.2/Common/plugins/ file too short

Checking the content of the lib/ folder revealed an interesting thing:

-rw-r–r– 1 jholy jholy   17 2010-02-16 23:16
-rw-r–r– 1 jholy jholy   21 2010-02-16 23:16
-rwxr-xr-x 1 jholy jholy 100K 2010-02-16 23:16

As also the content of the two small files suggests (they contain a name of the corresponding file with a longer name), the *.so and *.so.4 files should have been links but the installer failed to create them.


List all files in the lib/ folder, you will see that there are many real files like and and many should-be-links files. The solution is, of course, to replace all those files that shoud be links with actual links.

For me the solution was:

$ cd .../plugins/
# Move out the files that are OK
lib$ mkdir tmp
lib$ mv libswt-* tmp/
# Fix the links
lib$ for FILE in `ls *.so`; do ln -sf "${FILE}.4.5.0" $FILE; ln -sf "${FILE}.4.5.0" "${FILE}.4"; done
# Move the correct files back
lib$ mv tmp/* .
lib$ rmdir tmp
# Fix links for files with *.26 instead of *.4.5.0
lib$ ln -sf
lib$ ln -sf
lib$ ln -sf
lib$ ln -sf
lib$ rm
# Done!

Try to open the profile configuration now, the IWATO435E should have disappeared and you should be able to select a data collector.

If not, restart Eclipse, try again, check the error log.

My environment

  • Ubuntu 9.04
  • Eclipse 3.5
  • TPTP – see above


There is a similar post of the same problem but with different cause: Get Eclipse TPTP to run on Ubuntu Karmic Koala – the cause was: “the Agent Controller was built against old C++ libraries which were no longer available on my system (Ubuntu 9.10 Karmic Koala, amd64)”.

Posted in eclipse | Tagged: , , , , | Comments Off on Eclipse Profile configuration: The launch requires at least one data collector