Java snippets and utilities