Tag Archives: java

Java Programming Tips

Learn JShell Java 9 ships with jshell which provides an interpretive shell-like environment (a REPL) for Java. This is extremely useful for prototyping, testing and learning how to use a new library. Here I describe how to use it in … Continue reading

Posted in Computers, programming, Software | Tagged , | Leave a comment

Running Java in a Jupyter Notebook

Yes it is possible using IJava or Ganymede. In this post I describe all the steps I followed to get it to work on a Macbook using IJava. The post assumes you have python3, pip3 and JDK >= 9 installed. … Continue reading

Posted in Computers, programming, Software | Tagged | Leave a comment

How to measure memory in Java?

Unlike C#, Java does not have a built-in sizeof operator that can return the memory (bytes) consumed by an object. You can however do-it-yourself. The steps are a bit involved and hence summarized below. Here is link to SO answer … Continue reading

Posted in Computers, programming, Software | Tagged | Leave a comment

How to debug java.lang.ClassNotFoundException

java.lang.ClassNotFoundException is probably the most dreaded and difficult exception you can run into when doing Java development. What does it mean? Simply put, the class could not be found on the classpath. If you reached this far, the class was … Continue reading

Posted in Computers, programming, Software | Tagged | Leave a comment

Adding Logging to your Java application

Recently I had the “pleasure” to add logging to a Java application. It was the most difficult thing to do in the whole program. There is so much documentation available and no two web pages are alike. Which is correct … Continue reading

Posted in Computers, programming, Software | Tagged , , , | Leave a comment

The right way to implement producer consumer pattern in Java

The producer consumer pattern can be “easily” implemented in Java using one of the BlockingQueue classes. The producer puts work into the queue and consumer takes work from the queue. We start two separate threads for the producer and consumer. … Continue reading

Posted in Computers, programming, Software | Tagged , , , | Leave a comment

Validating PDFs

Sometimes you need to validate a PDF file. Here are step by step instructions on how to do so. Prerequisites: You need to have Java installed on your machine. Download preflight-app-2.0.21.jar from https://pdfbox.apache.org/download.cgi Run it passing the path to your … Continue reading

Posted in Software | Tagged , , | Leave a comment

Extracting images from a PDF

Sometimes you need to extract images inside a PDF. Here are step by step instructions on how to do that. Prerequisites: You need to have Java installed on your machine. Download pdfbox-app-1.8.16.jar from https://pdfbox.apache.org/download.cgi. WARNING: version 2.0.21 will not work. … Continue reading

Posted in Software | Tagged , , | Leave a comment

Debugging java out of memory exception

Read http://stackoverflow.com/a/35963059/147530 to understand the nuances esp. if you are getting this error: Real world example: Needed to debug a service that would cause an OOM exception after running for a while. Wrote following script to periodically make requests to the … Continue reading

Posted in programming, Software | Tagged , | Leave a comment