In this post I’m about to figure out how to use the following things in Java project: How to leverage in-memory H2 database? Particularly configuring it in maven pom.xml How to to initialize and use H2 database via Hibernate? How to use JNDI naming for DB connectivity on Jetty? As a base for sample project I’ll take a tiny webservice…
How to use Jetty to run Java web application locally?
Development of enterprise level web applications always cause some extra effort to setup various components locally. For example, if production environment runs big and robust Web Application server, like IBM WebSphere or Oracle WebLogic, you might don’t want to install and run it locally. Either for performance, configuration or licensing obstacles. There is a reasonable alternative to run and debug…
How to run Oracle SQLcl client directly as a Java class (skip sql.exe)?
Oracle SQL Developer Command Line (SQLcl) is a free command line interface for Oracle Database. It allows you to interactively or batch execute SQL and PL/SQL. SQLcl provides in-line editing, statement completion, and command recall for a feature-rich experience, all while also supporting your previously written SQL*Plus scripts. Here is what is said about this tool by Oracle. As an…
How to configure Flying Saucer and OpenPDF to load CSS from java resources classpath?
This post is a follow-up of the previous one about How to convert HTML to PDF in Java ? The latter is about how to use Flying Saucer and OpenPDF libraries to convert Html content to PDF. The sample in there was simply using resources by providing system path to necessary files. In the real world you can’t go like this.…
How to convert HTML to PDF in Java ?
There is so common requirement to generate PDF for some online content or reporting data. Also there is number of ways doing it. For example you could deliver it by leveraging headless browser (like Chrome or an older, already not supported but verified by time – PhantomJs) or use some dedicated back-end library. Differences between the latter are most likely…
JUnit test and mock private methods with PowerMock
First of all it might sound a bit strange – test private method. Why shall I do it – its private, not exposed and tend to change or disappear at all during some code refactoring. Although we might need to mock private method to dissociate from whatever it does, all the complexity, just use an output it supposed to produce.…
Common usages of grep and find in Linux
It is so common need to dig some info in Linux remote machines where you have just a terminal access. Effectiveness of searching might be crucial in finding necessary files and content. Here are couple of commands come to help as: grep – search in file contents find – search by file name It happens that sometimes quite difficult to…
How to run Linux command in background? How to keep it running after leaving terminal session?
When working with remote server through terminal it is common to run some processes in background. For example to start zipping something, put it into background and keep working on something else. Or even start a process and leave it running when you quit a terminal session. A quite common example could be – start application server. You just need…
What is a functional interface in Java8? Quick explanation and sample.
Any interface with a single abstract method is a functional interface and its implementation may be treated as lambda expression. It can have only a single functionality. However a functional interface can have unlimited default methods. Note, that default methods have implementation and abstract methods – not. The latter can be only one in functional interface. When defining your own…
What is a method reference in Java8? Quick explanation and samples.
Method reference – Lambda expression, which calls known method, written in shorter, more compact way. This is how we can define it in a short way. There are 4 types of method references: Reference to a static method Reference to an instance method of a particular object Reference to an instance method of an arbitrary object of a particular type…