InputStream License

Hello,

I am trying to apply the license as an InputStream:
InputStream licPath= Aspose.class.getClassLoader().getResourceAsStream(“Aspose.Total.Java.lic”);
com.aspose.words.License wordLicense = new com.aspose.words.License();
wordLicense.setLicense(licPath);

Apparently, this works ok but the license has not been applied because the document has the “Evaluation only” message.

Thanks. I am wating for your answer.

@jbengoa,

You may try to validate the license if it is set or not. Visit the link Validate the License for details. Furthermore please also make sure that you have not modified your license file. The license file is digitally signed, so you cannot modify it. Even a single space can invalidate it.

The problem is that, when I do “InputStream licPath= Aspose.class.getClassLoader().getResourceAsStream(“Aspose.Total.Java.lic”);”, I can see the lic file correctly but, when I set the license, this variable becomes null, so the isLicensed method fails.

If I set the license as a String with a absolute path, it works fine.

So… what could be my problem?

@jbengoa,

From details, it is clear that you have a valid license and it is not expired. Please confirm if you are setting license in a separate thread and using API method in another thread (i.e multi-threaded environment)? This would help us in investigating the scenario and respond you accordingly.

Yes, the license is valid and it is set in the same thread

@jbengoa,

Thanks for your inquiry. Please add the resources folder into your Java project. Please check the attached image for detail. license test.png (33.6 KB)

We suggest you please read following web links.
Java – Read a file from resources folder
How do I add a resources folder to my Java project in Eclipse
adding resources in intellij for java project

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("Aspose.Total.Java.lic");
com.aspose.words.License lic = new com.aspose.words.License();
lic.setLicense(is);
System.out.println("License is set as : " + lic.isLicensed());