0

Hello I want to export java app that uses iText 7 with trial version. I have problem because I don't know how to attach licence. Normally I have it in Intellij project directory and when I compile and run it works, problem begins when I want to export it to jar file. I know that attaching licence file is a problem because when I comments line in which I read licence it works.

yole
  • 92,896
  • 20
  • 260
  • 197
Michał Urban
  • 113
  • 12
  • It sounds like you're running your app inside of an IDE. You need to give us more details about how your *END USERS* will be running the app. Specifically: Q: How is the app installed? Q: How is the app's CLASSPATH configured? See also: [IText FAQ: How do I load a license key?](https://developers.itextpdf.com/content/license-key-frequently-asked-questions/how-do-i-load-license-key) – paulsm4 Mar 10 '18 at 18:13
  • the end users will run jar file and app will be started – Michał Urban Mar 10 '18 at 18:56
  • @MichałUrban Make sure the jar is packaged correctly and includes all the files/resources required by the app to work. See http://stackoverflow.com/a/42200519/104891. – CrazyCoder Mar 12 '18 at 20:29

1 Answers1

1

Turning @CrazyCoder's comment into an answer. This isn't an iText issue, but a JAR building issue. The license file needs to be accessible by the JVM at runtime, which usually means including it inside the JAR file and accessing it using the class loader. The loadLicenseFile method also accepts an InputStream, which isn't addressed in the License Key FAQ.

LicenseKey.loadLicenseFile(LicenseKey.class.getResourceAsStream("/path/to/license/file/in/jar"));

Ben Ingle
  • 575
  • 2
  • 12