Wednesday, July 11, 2012

Monday, July 2, 2012

How to use use AllJavadoc class from Weka

Weka framework has a useful tool to generate Javadoc for your classes. It uses information that you provided in the sources to generate appropriate Javadoc automatically. This helps to update Javadoc when you update sources.

Under the cut I'll describe how to use this tool.

Wednesday, June 20, 2012

How to ignore a class in JUnit tests

You may need to ignore a whole class in a test folder, or just a single test in a test case. To do it you should use @Ignore annotation.

This is how you should import it:


To ignore a whole class just add @Ignore annotation to it:

If you do it none of the tests in the ignored class will be called by JUnit. Optionaly you can add a text comment to an ignore annotation:

If you want to ignore only a single test you should write:

or alternatively with text comment:

The other way to ignore a test is to remove @Test annotation. But if you add @Ignore annotation to your test method, JUnit will report that some methods in your test set were ignored and this can be used as a remainder to fix it later.

That's all.
Good luck.

Tuesday, June 12, 2012

How to fix hg error "no tool found to merge"

Hello.

Sometimes merging your changes with changes of other people you may encounter a problem when hg cannot merge a file and displays the following error:

This often happens with binary files, but if it happens with a text file, you are in trouble, because you definitely do not want to merge big files by yourself.
Under the cut I'll show a simple solution for this.

Saturday, June 9, 2012

How to change @author property in Netbeans 7

When you create a new class in Netbeans, it automatically create code like this:

To change the author name you should do the following:

Friday, June 1, 2012

How to install a jar into local Maven repository

Hello.
I often  face a problem when I need to use some Java library in my Maven based project, but this library is not available in any Maven repository and is distributed as a .jar file. In this post I'll describe two ways how to fix this problem.

Thursday, May 31, 2012

How to install Maven in Ubuntu 11.10

Installation of Maven in Ubuntu Linux is simple and straightforward.

First you need to download maven from Apache web-site.

Unpack it:
unzip apache-maven-3.0.4-bin.zip


I prefer to put all manually installed software to /opt but you can select /usr/local/bin or any other directory as well:
sudo mv apache-maven-3.0.4 /opt

Now let's create a symbolic link to this directory with a shorter name:
cd /opt
ln -s /opt/apache-maven-3.0.4/ maven

Now if things go wrong with this version we will be able to change it easily just by changing symbolic link.

The last thing we need to do is to specify where our maven executables are.
We need to add this line at the end of  ~/.bashrc:
export PATH=/opt/bin:${PATH}

or if you selected other directory:
export PATH=<path-to-maven-folder>/bin:${PATH} 

Now you need to close your shell and open it again, or do:
source ~/.bashrc

or just to execute the command you added to the end of your .bashrc in your shell.

Now you can check if your Maven works:
$ mvn --version
Apache Maven 3.0.4 (r1232337; 2012-01-17 08:44:56+0000)
Maven home: /opt/mavenJava version: 1.7.0_02, vendor: Oracle Corporation
Java home: /usr/lib/jvm/jdk1.7.0/jre
Default locale: en_GB, platform encoding: UTF-8
OS name: "linux", version: "3.0.0-20-generic", arch: "i386", family: "unix"

Everything seems to be OK.
That's all.
Good luck.

Wednesday, May 30, 2012

How to install OpenCV 2.4 on Ubuntu 11.10

In the Internet one can find a lot of manuals about how to install/build OpenCV 2.3 under Linux, but most of them are incomplete. So here I would like to write a manual that I would like to see, a manual that helps to build OpenCV without any problems.