按照以上路径设置license后,运行代码报如下错误:
Exception in thread “main” class com.aspose.psd.internal.Exceptions.InvalidOperationException: The license signature is invalid.
com.aspose.psd.License$a.a(Unknown Source)
com.aspose.psd.License.a(Unknown Source)
com.aspose.psd.License.setLicense(Unknown Source)
com.aspose.psd.examples.ModifyingAndConvertingImages.PSD.FormatTextPortions.main(FormatTextPortions.java:33)
at com.aspose.psd.License$a.a(Unknown Source)
at com.aspose.psd.License.a(Unknown Source)
at com.aspose.psd.License.setLicense(Unknown Source)
The error message you’re encountering, “The license signature is invalid,” typically indicates that there is an issue with the license file you are trying to use with Aspose.PSD. Here are some common reasons and their solutions:
License File Corruption: Ensure that the license file is not corrupted. You can try re-downloading it from the Aspose website.
Incorrect License File: Verify that you are using the correct license file for the specific Aspose product you are working with. The file name should match exactly what is expected in your code.
File Path Issues: Make sure the path to the license file is correct. If you are using a relative path, check that your program’s working directory is set correctly. You might want to use an absolute path to avoid this issue.
File Permissions: Ensure that your application has the necessary permissions to access the license file. If the file is located in a restricted directory, consider moving it to a more accessible location.
License Application Timing: Confirm that you are applying the license before any Aspose.PSD classes are instantiated or methods are called. The licensing must be set at the very beginning of your application.
Here’s a sample code snippet demonstrating how to apply the license correctly:
import com.aspose.psd.License;
public class LicenseTest {
public static void main(String[] args) {
License license = new License();
try {
license.setLicense("path/to/your/license/file/Aspose.PSDforJava.lic");
} catch (FileNotFoundException e) {
e.printStackTrace();
throw new RuntimeException("License file not found.");
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("Failed to apply license.");
}
}
}
Make sure to replace "path/to/your/license/file/Aspose.PSDforJava.lic" with the actual path to your license file.
If you’ve checked all of these aspects and still encounter issues, consider reaching out to Aspose support for further assistance.
actually,my code is this:
License license = new com.aspose.psd.License();
try {
license.setLicense(new java.io.FileInputStream(“/User/myname/Aspose.PSDforJava.lic”));
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
the fileinput path is a absolute path. The result is still wrong.
@churui could you please provide the license file. You can attach it to this topic - only moderators are able to get the file or send it to me via direct message, I’ll check it and then help you with or redirect your request to the sales team.