Free Support Forum -

Setting license key with relative path throws exception (Java)

I’m encountering an issue that was supposedly fixed in SLIDESJAVA-34512 where Aspose slides won’t load license files using a relative path. Specifically, this was the issue raised on Thread 62589. Words/Cells/etc all see the license file fine when it is placed in the same folder as the jar, but Slides only works when an absolute path to the license is used.

My testing was to put jars and license files into “C:/testjars”, add the jar I’m testing to the build path, then run some test java code. Today I generated a new temporary license and tested using Aspose versions 15.1, 15.11, 16.1, 17.1, 17.12 and 19.6. None of these releases fixed the problem. The test code was this:

public static void main(String[] args) throws Exception {
	//new com.aspose.cells.License().setLicense("Aspose.Slides.lic"); // The license is not valid for this product.
	//new com.aspose.words.License().setLicense("Aspose.Slides.lic"); // The license is not valid for this product.
	new com.aspose.slides.License().setLicense("Aspose.Slides.lic"); // License stream is not available for reading
	new com.aspose.slides.License().setLicense("C:/testjars/Aspose.Slides.lic"); // Works

Do relative license paths work for anyone else?


I have observed the requirements shared and request you to please share the details of issue incurring on your end on using relative license. Please also provide the Java and Operating System details as well on your end.

I’m running Windows 10 with Corretto OpenJDK version “1.8.0_212”

The problem is that I want to use the relative license path instead of absolute path. The Aspose Slides licensing documentation says I can put the license in the same folder as the aspose slides jar, and provides sample code. When I try the sample code, it keeps throwing this exception “License stream is not available for reading” in com.aspose.slides.License.setLicense().


I have observed your comments. Can you please share on which relative path you are placing license file. I mean whether with Java file or generated class file of program.

I put the license file into the JAR folder, not into my application. For example, right now I have:

My test application is in C:\Users\username\eclipse-workspace\Asposetest


Thank you for sharing the information. An issue with ID SLIDESJAVA-37692 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

Great, thank you.


We have internally discussed the issue and suggest you to please don’t use relative paths for setting license. Because of the license file is not an embedded-resource file and we can’t access it via getClass().getResource or getResourceAsStream methods. So we use to load the license and internal logic is dependent on the current working directory over which you have totally no control from inside the Java code.

But you can use this code to find out the current working directory and then build a correct path for the license file:
String workingPath = new File("").getAbsolutePath();

Thank you for the suggestion, but that doesn’t solve the issue as the current working directory is not where the JAR files reside.

Your documentation still says “In this example Aspose.Slides will attempt to find the license file in the folder that contain the JARs of your application.”

This feature works for other products (e.g. Words and Cells). Is it not possible to copy the license code from those products into Slides?


Thank you for sharing your feedback. I have associated information in our issue tracking system and will get back to you with feedback as soon as it will be shared.

The issues you have found earlier (filed as SLIDESJAVA-37692) have been fixed in this update.

Awesome. Thank you