TL;DR:
Java’s ImageIO has partial JPEG2000 support — it handles the jp2 subformat but not jpx. For complete, reliable JPEG2000 output without native dependencies, you need an external library. JDeli is a pure Java option that works as a drop-in ImageIO plugin and provides a direct API. A free alternative using native binaries is available via the jai-imageio-jpeg2000 library on GitHub.
Does Java support JPEG2000 natively?
Partially. ImageIO includes basic JPEG2000 support for the jp2 subformat, but jpx is not supported. Attempting to write jpx will fail silently:
// jp2 — may work with native ImageIO depending on Java version
File file = new File("/path/to/output.jp2");
boolean result = ImageIO.write(bufferedImage, "jpeg2000", file);
// jpx — returns false, no writer available
File file = new File("/path/to/output.jpx");
boolean result = ImageIO.write(bufferedImage, "jpeg2000", file);
// result = false
As with ImageIO.write() in general, always check the return value — it returns false rather than throwing when no suitable writer is found.
Which Java JPEG2000 library should you use?
| ImageIO (native) | jai-imageio-jpeg2000 | JDeli | |
|---|---|---|---|
| Pure Java (no native binaries) | ✓ | ✗ (wraps OpenJPEG) | ✓ |
| Works as ImageIO plugin | ✓ | ✓ | ✓ |
| Direct API | ✗ | ✗ | ✓ |
| jp2 support | ✓ | ✓ | ✓ |
| jpx support | ✗ | ✓ | ✓ |
| Encoder options | ✗ | Limited | ✓ |
| Supports other formats (AVIF, HEIC, PNG, TIFF, WebP…) | ✗ | ✗ | ✓ |
| Cost | Free | Free | Commercial |
| Support | Community | GitHub issues | Included |
| Actively developed | ✓ | Limited | ✓ |
jai-imageio-jpeg2000 is a reasonable free option if native binaries are acceptable in your environment and you only need ImageIO plugin behaviour. JDeli is the better choice for production use, pure Java environments, or where you need jpx support and encoder control.
Option 1: Write JPEG2000 with native ImageIO
For jp2 output, native ImageIO may be sufficient:
File file = new File("/path/to/output.jp2");
boolean written = ImageIO.write(bufferedImage, "jpeg2000", file);
if (!written) {
// No suitable ImageIO writer found
throw new IOException("Failed to write JPEG2000: no suitable writer found");
}
If you need jpx support, a third-party library is required.
Option 2: Add full JPEG2000 support to ImageIO (no code changes)
JDeli registers itself as an ImageIO plugin. Once it is on the classpath, your existing ImageIO.write() calls handle both jp2 and jpx automatically with no code changes required.
Maven
<dependency>
<groupId>com.idrsolutions</groupId>
<artifactId>jdeli</artifactId>
<version>[JDELI_VERSION]</version>
</dependency>
Gradle
implementation 'com.idrsolutions:jdeli:[JDELI_VERSION]'
Alternatively, download the trial jar and add it to your classpath manually. See the ImageIO configuration guide for setup details.
// Your existing ImageIO code — no changes needed
File file = new File("/path/to/output.jp2");
ImageIO.write(bufferedImage, "jpeg2000", file);
Option 3: Write JPEG2000 directly with the JDeli API
The JDeli API gives you more control and does not depend on ImageIO’s plugin registration order.
- Add JDeli to your class or module path. (download the trial jar)
- Create a
FileorOutputStreamfor the output. - Call
JDeli.write()with your image, format, and output target.
// String format
JDeli.write(bufferedImage, "jp2", new File("/path/to/output.jp2"));
// Type-safe enum (preferred)
JDeli.write(bufferedImage, OutputFormat.JPEG2000, new File("/path/to/output.jp2"));
Controlling output with Jpeg2000EncoderOptions
For production use, pass a Jpeg2000EncoderOptions object to control compression and other output settings:
Jpeg2000EncoderOptions options = new Jpeg2000EncoderOptions();
JDeli.write(bufferedImage, options, new File("/path/to/output.jp2"));
See the JDeli JPEG2000 documentation for the full list of encoder options.
Frequently asked questions
What is JPEG2000?
JPEG2000 is an image compression standard published in 2000 as a successor to JPEG. It supports both lossless and lossy compression, delivers better quality than JPEG at equivalent file sizes, and is used in medical imaging (DICOM), digital cinema (DCP), and archival workflows. The two main subformats are jp2 (the base format) and jpx (an extended profile).
What is the difference between jp2 and jpx?
jp2 is the base JPEG2000 file format. jpx is an extended profile that supports additional features including ICC colour profiles, transparency layers, and more complex metadata. Java’s native ImageIO handles jp2 only; jpx requires a third-party library such as JDeli.
Can I read JPEG2000 files in Java with JDeli?
Yes. See our companion article: how to read JPEG2000 files in Java.
Is JDeli pure Java?
Yes. JDeli has no native binaries and makes no calls to platform-specific libraries, making it straightforward to deploy on any Java-supported platform including containerised and server environments.
What is JDeli?
JDeli is a pure Java image library from IDR Solutions. It supports reading, writing, and converting JPEG2000 and other formats including AVIF, HEIC, PNG, TIFF, and WebP. It works as both an ImageIO plugin and a standalone API.
Other useful JPEG2000 resources
As experienced Java developers, we help you work with images in Java and bring over a decade of hands-on experience with many image file formats.
Are you a Java Developer working with Image files?
// Read an image
BufferedImage bufferedImage = JDeli.read(avifImageFile);
// Write an image
JDeli.write(bufferedImage, "avif", outputStreamOrFile);// Read an image
BufferedImage bufferedImage = JDeli.read(dicomImageFile);// Read an image
BufferedImage bufferedImage = JDeli.read(heicImageFile);
// Write an image
JDeli.write(bufferedImage, "heic", outputStreamOrFile);// Read an image
BufferedImage bufferedImage = JDeli.read(jpegImageFile);
// Write an image
JDeli.write(bufferedImage, "jpeg", outputStreamOrFile);
// Read an image
BufferedImage bufferedImage = JDeli.read(jpeg2000ImageFile);
// Write an image
JDeli.write(bufferedImage, "jpx", outputStreamOrFile);
// Write an image
JDeli.write(bufferedImage, "pdf", outputStreamOrFile);
// Read an image
BufferedImage bufferedImage = JDeli.read(pngImageFile);
// Write an image
JDeli.write(bufferedImage, "png", outputStreamOrFile);
// Read an image
BufferedImage bufferedImage = JDeli.read(tiffImageFile);
// Write an image
JDeli.write(bufferedImage, "tiff", outputStreamOrFile);
// Read an image
BufferedImage bufferedImage = JDeli.read(webpImageFile);
// Write an image
JDeli.write(bufferedImage, "webp", outputStreamOrFile);
What is JDeli?
JDeli is a commercial Java Image library that is used to read, write, convert, manipulate and process many different image formats.
Why use JDeli?
To handle many well known formats such as JPEG, PNG, TIFF as well as newer formats like AVIF, HEIC and JPEG XL in java with no calls to any external system or third party library.
What licenses are available?
We have 3 licenses available:
Server for on premises and cloud servers, Distribution for use in a named end user applications, and Custom for more demanding requirements.
How does JDeli compare?
We work hard to make sure JDeli performance is better than or similar to other java image libraries. Check out our benchmarks to see just how well JDeli performs.
