How to install Oracle Java 8 on Ubuntu (in may case, Ubuntu 16.04 LTS) Procedure to install Oracle Java 8 on Ubuntu You probably want to confirm first that a version of Java is not already installed. If so, you can do that with the java -version command as shown below… developer@ubuntu:~$ java -version The program ‘java’ […]

Need a quick and easy caching system for your web app? Don’t you dare roll your own. And don’t even think about doing some kind of quick and dirty HashMap. Setting up a simple cache with Commons JCS™, is easy – you can have a basic LRU Cache up and running in minutes. What’s more, the package […]

Recently, we experienced some excessive memory consumption that was leading our servers into an out-of-memory (OOM) condition. To troubleshoot the issue, we needed a way to identify any large objects that were filling up the heap. As it turns out, there’s a JVM argument for this. Generic JVM argument: -Xdump:stack:events=allocation,filter If you set this option, whenever […]

When you use renderRequest, renderResponse, and portletConfig objects in a JSP, your Rational or Eclipse-based IDE will usually give a validation error – “renderRequest cannot be resolved,” for example. Having red-x validation errors in your IDE is annoying as all-hell, so here’s a nice work-around for that… <%@ page import=”javax.portlet.RenderRequest” %> <%@ taglib uri=”” prefix=”portlet”%> […]

With Servlet 3.0, it’s now possible to define your servlet using annotations instead of XML in the web deployment descriptor (web.xml). This can simplify maintenance and deployments because it keeps the servlet definition inline with the servlet’s actual code – everything’s conveniently found and managed together in one file. For those of you ready to […]

Did you know there’s a tool that can help you search through JAR files to find Java classes or packages? I’ve been using it for years and I am often surprised that so few Java developers have it in their toolbox. Of course, it’s very handy for resolving those pesky NoClassDefFoundError and ClassNotFoundExceptions, but my […]

A Java ClassNotFound exception does not always mean that a class could not be found on the classpath. It seems that sometimes it can mean that the class was actually found 2 or more times – a conflict in the classloader. Recently, while developing a portlet for WebSphere Portal, I got the following exception: Caused […]

Render the values of a Map The following code snippet shows how to get the values of a Map (e.g. HashMap) from within a Freemarker template. <#assign m = myMap> <#assign values = m?values> <ul> <#list values as myObject> <li>${myObject.myPropery}</li> </#list> </ul> Render the keys of a Map You can do a similar thing with […]