Category Archives: Java

Show PDF Files With PrimeFaces

It is pretty easy to preview pdf files with PrimeFaces media component as explained in official page.

If you try this already there are two common problems that may find you.

  • Shows the same file every time
  • Cannot download the file multiple times (if you have an extra download button even the pdf viewer already have one)

Continue reading

Struts 2 Hello World With Eclipse, Maven and Jetty

I just adapted mkyong’s Struts-2 tutorial [1] to work with embedded Jetty in Eclipse.

How Project Explorer looks like:


Continue reading

SOAP Web Service Server and Client Example With Apache CXF and Eclipse

Let’s create a simple standalone web service example with Apache CXF. First, we are going to build a server then generate a client to send a request to our web service.

Continue reading

Grunt Maven Integration

You may want to integrate Grunt and Maven to be able to build frontend every time just before a Maven build.

For this purpose, I prefer to use exec plugin to invoke “grunt build” in the beginning of each Maven build.

Click to read more…


Creating a RESTful web service with Spring is pretty easy as mentioned in here [1] and here [2].

Let’s make an example.

Create a new Dynamic Web Project and convert to Maven Project in Eclipse.
Click to read more…

RESTFul Web Service Example with Jersey 2 and Tomcat 8

Jersey RESTful Web Services framework is open source, production quality, framework for developing RESTful Web Services in Java that provides support for JAX-RS APIs and serves as a JAX-RS (JSR 311 & JSR 339) Reference Implementation.

Let’s make an RESTFul web service example with Jersey 2 and Tomcat 8. Our web service is taking a word as parameter, reverse it and return that reversed word as response.

Click to read more…

AngularJS & Java Servlet POST Request Example

I tried simple POST request with AngularJS but it didn’t work properly, then looked for solution in stackoverflow and found answer in here [1]. According to that explanation I wrote simple snippet.

Click to read more…

Communication Between Java Applications (3) – ActiveMQ

ActiveMQ is a popular library to use messaging via JMS.

There is a very good “Hello World” tutorial exists in offical site, I must say.

So I’m going to write another “Hello World” example with ActiveMQ, but I also show you how you can get statistics (enqueue/dequeue count etc.) in your code.

ActiveMQ architecture simply consist of a producer which sends messages to a broker and a consumer which listens that broker to receive messages. We will create a Queue on this broker to keep messages.

Click to read more…


Using Google Guava For Cache With Timeout – Java

If you need a list to keep your objects for a while and then automatically delete/expire them, you can use caches from Google Guava.

The Guava project contains several of Google’s core libraries that we rely on in our Java-based projects: collections, caching, primitives support, concurrency libraries, common annotations, string processing, I/O, and so forth.

The latest release is 18.0, released August 25, 2014.

First, let’s write a class based on LoadingCache.

Click to read more…


Communication Between Java Applications (2) – JGroups

JGroups is a library which may serve some APIs to communicate between java applications. Unfortunately it is a little bit complex and has some advanced configurations, so I just show quick and simple example to introducing.

Project Explorer is going to looks like this:

Click to read more…