I have purchased the license for aspose.pdffor java.
Currently my project folder is as below
ProjectName
src
main.java ( in this i am setting license with the code PDFLicense.setLicense(“Aspose.PDF.Java.lic”);
lib
asposepdf.jar
Aspose.PDF.Java.lic
It worked fine when i tested from eclipse.
Now I have created executable jar file and deployed in Unix.
When i am running the jar file in Unix, getting the below error
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.substring(String.java:2684)
at com.aspose.pdf.l10y.lf(Unknown Source)
at com.aspose.pdf.l10y.lj(Unknown Source)
at com.aspose.pdf.l10y.lI(Unknown Source)
at com.aspose.pdf.License.setLicense(Unknown Source)
But if I place the license file in the unix folder where jar file is there…it is working fine. But I don’t want to place the license file seperately in unix box. How can i achieve that ??
Project folder structure in screenshot is as below
image.png (4.1 KB)
@manjularani
Please make sure that you are using Aspose.PDF for Java to set the license. It seems that you are using Aspose.BarCode for setting PDF license.
Please use the following code example to set the license.
// Initialize License Instance
com.aspose.pdf.License license = new com.aspose.pdf.License();
// Call setLicense method to set license
license.setLicense("Aspose.Pdf.Java.lic");
Hi Tahir,
I am using Pdf license only.
com.aspose.pdf.License PDFLicense= new com.aspose.pdf.License();
PDFLicense.setLicense(“Aspose.PDF.Java.lic”);
The issue is, when i run and test the project from eclipse…everything is working fine. But when i generate executable jar file and run in Unix, i am getting the error.
@manjularani
In your case, we suggest you please add the license into your project as embedded resource. Please read following web article.
Read a file from resources folder
Following code example shows how to read the license file from resources folder. Hope this helps you.
ClassLoader cl = Thread.currentThread().getContextClassLoader();
InputStream is = cl.getResourceAsStream("license file name...");
com.aspose.pdf.License lic = new com.aspose.pdf.License();
lic.setLicense(is);
Thanks tahir. Will try this and let you know if i face any issues.
@manjularani
Please feel free to ask if you have any question about Aspose.PDF, we will be happy to help you.