suda Senior Java EE Develope specialises in Pdf forms , Fonts, application servers and Image manipulation, meditates in spare time.

Fixing bugs in the Java JPEG2000 library – getting the source code to run

1 min read

In 2 previous blog posts, my colleague Daniel wrote about finding a memory leak in the Java JPEG2000 library and the source code change. I have been looking at another bug  so I thought a series of articles on the subject would be of interest.

To use JPEG2000 images in Java, you need to use some additional libraries. These seem to have been abandoned by Oracle but luckily you can still get the source code to debug. This article is about how to get the source code and set it up to run in an IDE (I have used Eclipse as an example);.

Downloading the source

The first step is to get the Java code.

You can download the source code from Oracle with this command

svn co

Don’t forget to include Daniel’s patch for the memory leak which you can get here.

Set the source as your src

The SVN repositry actually contains not only the source code bu also jars needed to run the code and build tools. The source code for the actual JPEG2000 plugin is hidden in trunk/src/share/classes – we added a link to this so we could preserve the SVN structure and still have the correct package locations. You will also need the 2 JAI jars (jai_core.jar and jai_codec.jar) and trunk/src/share/jc4libjai/clibwrapper_jiio.jar to compile the source.

Hacking the source to run

To get the code to run, I found that I had to hack the PackageUtil class. Once you have downloaded and configured the project, hack the vendor code  in the package by setting version and vendor details as you can see in this screenshot.

Java code to edit

The actual JPEG2000 code is mainly found in jpeg2000 library plug-ins can be found in the package called; I will be looking at this in more detail in later articles…

Now you are ready to start hacking the code!

In the end we gave up with trying to patch ImageIO and JAI and wrote our own ImageIO replacement from scratch. Lots of other developers seemed to have the problems so we made this commercially available as the JDeli Image library. You can find out more on the JDeli page.

Why use JDeli?

JDeli offers a range of advantages over ImageIO and alternatives, including:

  • prevents heap related JVM crashes
  • implements unsupported image formats
  • reduce output file size
  • improve read/write performance
  • supports threading
  • superior image scaling algorithms

Our software helps Java Developers to

View PDF files in a web application →

Parse PDF files as HTML →

Display PDF Forms in a web browser →

View PDF Documents in Java Applications →

Rasterize PDF Documents to image →

Read/Write images (including HEIC, JPG and WEBP) →

Convert Image files to PDF Documents →

suda Senior Java EE Develope specialises in Pdf forms , Fonts, application servers and Image manipulation, meditates in spare time.

Leave a Reply

Your email address will not be published. Required fields are marked *

IDRsolutions Ltd 2022. All rights reserved.