Applying License Keys in IronPDF for Java
Applying a license key to IronPDF for Java unlocks full production capability. Without a valid license key, IronPDF runs in trial mode and stamps a watermark on every generated PDF — acceptable for development and evaluation, but not suitable for live deployment. This guide walks through three ways to apply a license key: in Java code at startup, via a config.properties file, and how to verify the key is active.
Quickstart: Apply an IronPDF License Key in Java
How Do You Get an IronPDF License Key?
IronPDF for Java is free to evaluate in development. In trial mode, every PDF produced carries an IronPDF watermark. To remove the watermark and deploy to production, a paid or trial license key is required.
Two options are available:
- Purchase a license — visit the IronPDF Java licensing page to choose a plan that fits your deployment needs.
- Start a free 30-day trial — request a trial license key to evaluate IronPDF without restrictions in a live environment.
Once the key arrives by email, keep it available for the steps below. The same key works for code-based and file-based application methods.
How Do You Add IronPDF as a Java Dependency?
Before applying a license key, IronPDF must be on the classpath. There are two ways to achieve this: declare it as a Maven dependency or add the .jar file manually.
Option 1: Maven (pom.xml)
Add the following two entries to the <dependencies> block in your pom.xml. The first pulls in the IronPDF library; the second adds the SLF4J logger that IronPDF uses internally.
//:path=pom.xml
<dependencies>
<dependency>
<groupId>com.ironsoftware</groupId>
<artifactId>ironpdf</artifactId>
<version>20xx.xx.xxxx</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.3</version>
</dependency>
</dependencies>
//:path=pom.xml
<dependencies>
<dependency>
<groupId>com.ironsoftware</groupId>
<artifactId>ironpdf</artifactId>
<version>20xx.xx.xxxx</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.3</version>
</dependency>
</dependencies>
Replace 20xx.xx.xxxx with the latest IronPDF for Java version. After saving pom.xml, run mvn install (or let your IDE sync) to download the dependency.
Option 2: Manual JAR
If Maven is not part of the build toolchain, download the IronPDF Java .jar file and add it to the project's classpath manually. This approach suits Ant-based builds or projects that manage dependencies without a package manager.
How Do You Apply a License Key in Java Code?
The most direct method is to call License.setLicenseKey() at the very beginning of application startup — before any PDF operation runs. Placing the call in the main method is the safest approach.
//:path=MyApplication.java
import com.ironsoftware.ironpdf.License;
public class MyApplication {
public static void main(String[] args) {
// Apply your license key before using any IronPDF feature
License.setLicenseKey("IRONPDF-MYLICENSE-KEY-1EF01");
// IronPDF is now fully licensed — no watermarks on output PDFs
System.out.println("IronPDF license applied.");
}
}
//:path=MyApplication.java
import com.ironsoftware.ironpdf.License;
public class MyApplication {
public static void main(String[] args) {
// Apply your license key before using any IronPDF feature
License.setLicenseKey("IRONPDF-MYLICENSE-KEY-1EF01");
// IronPDF is now fully licensed — no watermarks on output PDFs
System.out.println("IronPDF license applied.");
}
}
This approach works in all Java project types: standalone applications, Spring Boot services, Jakarta EE applications, and Android projects. The key is stored in memory for the lifetime of the JVM process; no file system writes occur.
How Do You Apply a License Key Through a Config File?
For projects that separate configuration from code — such as twelve-factor applications or deployments that rotate keys without a redeploy — the config.properties file method is preferable.
Add one line to config.properties:
//:path=config.properties
IRONPDF_LICENSE_KEY=IRONPDF-MYLICENSE-KEY-1EF01
Place the file in the working directory of the running application or on the classpath root. IronPDF reads this property automatically at startup. No code changes are required when the key changes — update the file and restart the process.
How Do You Verify That the License Key Is Active?
After applying a key by either method, License.isValidLicense() confirms whether IronPDF recognizes it as valid. Add this check to a startup routine or a health-check endpoint.
//:path=LicenseVerification.java
import com.ironsoftware.ironpdf.License;
public class LicenseVerification {
public static void main(String[] args) {
String licenseKey = "IRONPDF-MYLICENSE-KEY-1EF01";
// Returns true if the key is valid and the license is active
boolean isValid = License.isValidLicense(licenseKey);
if (isValid) {
System.out.println("License is valid — watermarks are disabled.");
} else {
System.out.println("License is invalid or expired. PDFs will include a trial watermark.");
}
}
}
//:path=LicenseVerification.java
import com.ironsoftware.ironpdf.License;
public class LicenseVerification {
public static void main(String[] args) {
String licenseKey = "IRONPDF-MYLICENSE-KEY-1EF01";
// Returns true if the key is valid and the license is active
boolean isValid = License.isValidLicense(licenseKey);
if (isValid) {
System.out.println("License is valid — watermarks are disabled.");
} else {
System.out.println("License is invalid or expired. PDFs will include a trial watermark.");
}
}
}
License.isValidLicense() returns true when the key format is correct, the license has not expired, and the key matches the product. It returns false for malformed keys, expired trial keys, or keys issued for a different Iron Software product. After any license change, clean and rebuild the project before running this check to avoid stale class data affecting the result.
| Behavior | Trial Mode (no key) | Licensed Mode |
|---|---|---|
| PDF watermark | Yes — on every page | No |
| Production deployment | Not permitted | Permitted |
| Feature access | Full API available | Full API available |
| License.isValidLicense() | Returns false |
Returns true |
What Are the Next Steps?
With a valid license key applied, IronPDF for Java is ready for production use. The following resources help move from setup to implementation:
- Get Started with IronPDF for Java — the official getting-started tutorial covering HTML-to-PDF rendering, PDF reading, and common document operations.
- IronPDF Java Code Examples — a library of runnable examples covering PDF creation, editing, stamping, form filling, and more.
- IronPDF Java API Reference — full method and class documentation for the
com.ironsoftware.ironpdfpackage. - Purchase or upgrade a license — scale from a single developer license to an enterprise or OEM deployment as the project grows. Start a free trial if evaluation is still ongoing.
For technical questions, the IronPDF support team is available via live chat and email.
Frequently Asked Questions
What happens if I use IronPDF for Java without a license key?
Without a valid license key, IronPDF runs in trial mode and stamps a watermark on every PDF page it generates. All API features remain accessible, but watermarked output is not suitable for production deployment.
How do I get an IronPDF license key for Java?
Purchase a license on the IronPDF Java licensing page, or request a free 30-day trial key. Both options remove the trial watermark and allow production use for the license duration.
How do I apply an IronPDF license key in Java code?
Call License.setLicenseKey("YOUR-LICENSE-KEY") at the very start of your application, before any other IronPDF class or method is used. The key applies for the lifetime of the JVM process.
How do I apply a license key using a config.properties file?
Add the line IRONPDF_LICENSE_KEY=YOUR-LICENSE-KEY to your config.properties file and place the file in the application working directory or classpath root. IronPDF reads it automatically at startup.
What does License.isValidLicense() return?
It returns true when the key is correctly formatted, has not expired, and matches the IronPDF product. It returns false for malformed keys, expired trial keys, or keys issued for a different Iron Software product.
Does the license key method differ between Java and .NET versions of IronPDF?
Yes. In Java, the class is com.ironsoftware.ironpdf.License and the method is License.setLicenseKey(). In .NET, the equivalent is IronPdf.License.LicenseKey set as a property. The key format is shared across platforms for multi-platform licenses.
Which Java project types does code-based license application support?
The License.setLicenseKey() call works in standalone Java applications, Spring Boot services, Jakarta EE applications, Android projects, and any other JVM-based runtime.
Do I need to rebuild my project after changing the license key?
When using the code-based method, yes — clean and rebuild to avoid stale compiled classes. When using config.properties, a process restart is sufficient without a full rebuild, which makes it easier to rotate keys in production.


