Category Archives: Java

Java Mockito Common Uses (Mock Static, Mock Private…)

In this project, we will be discussing some mockito common uses: Mock a method Mock a private method Mock a static method Mock a private static method Before starting, let’s look at the required dependencies and the Class used for … Continue reading

Posted in Java, Uncategorized | Leave a comment

Spring MVC: Return a JSON object

In a Spring MVC project, we can directly return a JSON object. This feature is very useful when combined with ajax request from the client side. Here is few simple step to do this: Import JSON dependencies (jackson library) to … Continue reading

Posted in Java, Spring | Leave a comment

Spring MVC: Creating a Project from Scratch using Maven

If you don’t want to use Spring STS to create your Spring MVC project, you can, of course, create it from the scratch. And here is what we will need to do: Create a java web project using maven Test … Continue reading

Posted in Java | 1 Comment

Easy to remember: Composition vs Aggregation

As a rule of thumb: In composition (Person, Heart, Hand), aggregated objects (Heart, Hand) will be destroyed as soon as Person is destroyed. In aggregation (City, Tree, Car) aggregated objects (Tree, Car) will NOT be destroyed when City is destroyed. … Continue reading

Posted in Java | Tagged , | Leave a comment

Import an existing Maven-based project to eclipse

Create a new Maven Project (if you already have one, just skip this step) $ mvn archetype:generate -DgroupId=package.name.ProjectName -DartifactId=ProjectName -Dpackage=package.name -Dversion=1.0-SNAPSHOT When asked, just keep the default configuration. It means that we’re going to use maven-archetype-quickstart archetype Convert it to … Continue reading

Posted in Java | Tagged , | Leave a comment

Simple Text To Speech in Java based on Google Translate API

Google Translate is one of the most powerful Google Services, it helps us to translate text from one language to another language. The good thing is that it also pronounces the translating (or translated) text. You can try it yourself … Continue reading

Posted in Java | Tagged | 2 Comments

Hadoop Mapreduce word count using eclipse

This article describes how to create a word count example using Eclipse. Requirement Eclipse Juno 32bit JDK 6.xx Latest Hadoop version (At the time of this writing, 1.0.4 is the lastest stable version) Linux Ubuntu 12.04 (although we can use … Continue reading

Posted in Java | Tagged , | 4 Comments