Skip to main content

Profile your applications with Java VisualVM
   Posted:


When you need to discover what part of an application consume the more CPU or Memory, you must use a profiler to do that.

One profiler, packed by default with the Sun JDK is Java VisualVM. This profiler is really simple to use and really powerful.

VisualVM start logo

In this post, we'll see how to install it and use it to profile an application.

Read more…

Comments

Version Control with Git – Book Review
   Posted:


After I had chosen to switch to Git, I thought the time has become to read a complete book on the subject to understand the concepts of Git from the base to further level.

So I chose "Version control with Git", from Jon Loeliger

I just finished to read it, so I will try to give my impressions about this book on this post.

Version control with Git

Read more…

Comments

JR Virtual machines
   Posted:


Until now, we've always had concurrent program working in one virtual machines, but JR provides ways to declare several virtual machines on several different physical machines. A JR Virtual Machine contains a Java Virtual Machine and a layer for the JR language. Once you created some virtual machines, you can specify where an object will be created with a variant of the new operator. After that, almost all the development is transparent. By example, a send operation on an operation serviced by an other virtual machine is exactly the same as if there is only one virtual machine. You can do exactly the same thing. We'll see that there is some differences, but it's really easy.

An important thing to remember is that all the virtual machines created contains the static part of the application. So all the static part is local to the virtual machines. This can cause really difficult bug to solve if we don't take care.

Read more…

Comments

Java SE 6 Update 21 Released
   Posted:


Oracle has just released the Java SE 6 Update 21.

This version is compatible with new system configurations :

  • Oracle Enterprise Linux 5.5, 5.4, 4.8
  • Red Hat Enterprise Linux 5.5, 5.4
  • Oracle VM 2.2.0.0.0
  • Google Chrome 4.0

This version integrate the Java Hotspot VM 17.0. There is several improvements, by example in compressed object pointers, escape analysis, code cache management, Mark-Sweep and G1 garbage collection algorithms. You can enable G1 with

-XX:+UnlockExperimentalVMOptions -XX:+UseG1GC

This version integrate also the last version of Java Visual VM, the 1.2.2. For more informations, consult the VisualVM official site.

There is an important bug fix about drag and drop. There is no security updates on this update. The list of BugFixes on the site of Java.

You can now add a progress indicator in Applet and Java Web Start applications really easily. For informations, you can consult this list of tutorials.

For complete informations about the release, consult the release notes of Java SE 6 Update 21.

Comments

Modular Java – Book Review
   Posted:


Some weeks ago, I finished "Modular Java - Creating Flexible Applications With OSGi and Spring", it's time to do a little review now.

Modular Java

This book is an excellent introduction to the creation of modular applications in Java. It introduces all the main concepts of the OSGi technology, Spring Dynamic Modules and tools making easier the development of OSGi applications.

The first chapter introduce the concept of modularity and explain how OSGi solve the problem. The main characteristics of the technology are also described.

The next chapter lists the main OSGi containers and we create the first Hello World using OSGi. Next we improve this simple program using an OSGi service.

After that the third chapter introduce the application "Dude, Where is my Jar ?". This application is a simple web program allowing a develop to search for a Jar file in Maven repositories. This application is used in all the next chapters. More than this introduction, the chapter also shows how the Pax tools can make easier the development of OSGi applications.

In the next chapter, we create the first bundle of the application. With that bundle we see how to work with non-bundle dependencies. And in the next one, we create the services of the application and see how to publish and consume services.

After that, it's time to use Spring Dynamic Modules with the next chapter. We see how to publish and consume services with Spring.

In the seventh chapter, we develop the web bundle. Fort hat, we include Tomcat or Jetty in the form of OSGi Bundles. We also see the differences between a simple bundle (Jar) and a web bundle (War).

In the next, we see how to extend OSGi bundle using fragment. With that, we see how to separate the JSP part of the application.

The last two chapters are about the deployment in production of an OSGi application and the services offered by the OSGi standard (logging, admin, console, ...).

In conclusion, this book will allows you to start developing application using OSGi. It's really comfortable to follow the development of a simple applications during the entire book. And improve it with each concept of the technology. But I think it's not a very good idea to use that log the Pax Tools. We quickly loose OSGi with Pax. It's quite interesting to know how to use Pax (I use it everyday), but when we start, it's better to see the basic concepts further.

And more, the Maven output, is almost entirely displayed. This not really useful to see that every time when it's not errors, warning or important informations. But nevertheless, the reading of the book is really comfortable and fluid.

Comments

Rendezvous, concurrency method, in JR
   Posted:


In this post, we'll see a new feature of JR : the rendezvous.

Like asynchronous message passing, this synchronization method involves two processes : a caller and a receiver. But this time, the invocation is synchronous, the caller delays until the operation completes. The rendezvous does not create a new thread to the receiver. The receiver must invoke an input statement (the implementation of rendezvous) and wait for the message. Like asynchronous message passing, this is achieved using operations as message queue.

Read more…

Comments

Tip Replace an old copyright by a new one
   Posted:


Today, I searched a tool to replace the old copyright of the GNU GPL V3 license by the copyright of the Apache License 2.0. But I've not found a simple tool to do a multi-line replacement in a complete set of files. So like the developer I'm, I decided to do it myself. And because it can be useful to someone else and because open source is good, I also decided to give it to everything that want :)

The usage is quite simple :

java -jar RCR.jar old_file new_file file
  • old_file is the path to a file containing the old copyright
  • new_file is the path to the file containing the new copyright
  • file is a folder to make the replacements in. If it's a folder, all the files and sub-folders will be searched for replacements.

Here, I'm talking about a copyright, but it of course also works for any other multi-line replacement you want.

The jar is available here : RCR.jar

The sources is available here : RCR.java

I hope that will be useful to someone.

Comments

Getting started with Play Framework
   Posted:


It's time for me to test the Play Framework and I'll try to make some posts during my tests about this web framework.

Play Framework is a framework to create web applications in Java. The main goals of this framework are (according to the official site) :

  • Hot reload : You can edit your java files and html files and you just have to refresh the browser to see the results
  • Stateless model : Play is ready for REST, it can be scaled running multiple instances of the same applications on several servers
  • Efficient Template System : The template system is really easy to use, based on Groovy.
  • Resolve errors quickly : When an error occurs, Play displays directly the code source in the browser and the location of the error
  • Integration : Play provide integration for Hibernate, OpenID, MemCached and others popular frameworks
  • Pure Java : You make only Java and HTML, no other things to learn and easy integration in IDE.
  • Fast : The startup of application is really fast the rendering of the pages also very fast.

In this post, we'll see how to install the Play Framework and how to write our first Hello World.

Read more…

Comments

Tip : How to solve “agent admitted failure to sign using the key” error ?
   Posted:


A very simple tip that can save a lot of time.

When i wanted to do a git clone, I had the given error :

Agent admitted failure to sign using the key.
Permission denied (publickey).

I found that this is an SSH error.

One of the readers, Leonardo Hessel, pointed that out that ssh-add is also a solution:

ssh-add

Another solution is simply to login and logout and it should work.

Comments