Java SE

Memory Profiling for Novices ( Heap OutOfMemory OOME error )

So sometimes out of memory errors crop up in you application. But to troubleshoot these should not be that complicated. Let me show you with Oracle's Visual VM, how you can quickly get down to the root cause of your out of memory errors. All you need Oracle's Java JDK installed on your system and the VisualVM tool that comes with it. At the time of writing the version I used was with JDK 8 (1.8.0_144). On a Mac OSX system all you need to do is type "jvisualvm" on your terminal and it will just popup. If you have your paths properly setup under windows and linux, it should also just work.

Lambda Recipe for attribute validation of Collection of POJOs

So here is a recipe you can use to validate a POJO attribute for some value. In my case I will show you how to check if attributes were set to null. But you can expand on the example as an exercise for yourself.

So here is the template method for a single object and a collection of objects:

Regex Lookahead and Lookbehind : Match Prefix and Suffix string but only accepting anything in between

Reg ex, lookahead, lookbehind

So there is a little known construct in regex of lookahead and lookbehind, that java regex also supports atleast upwards from java 5. This is exactly what you need if the desired match lives between a known prefix and suffix String. Or depending on if you have a prefix you can use the lookbehind construct and if you have a suffix only, you can use the lookahead construct.

So the lookbehind is represented by (?<=X) and lookahead is represented by (?=X).

Java keytool command references

Here are some commands I just found lying around that I once used when working with SSL enablement for a product. I think they should be useful examples for some one wanting to work with the keytool. So decided to just put these out there simply.

First a quick quotation from Oracle Java what the keyool is and does from their doc page here. ( I have linked to java se 6 docu as I believe that is what I actually used for the example commands ) :

Subscribe to RSS - Java SE