Hi Team,
When trying to print a docx file using Aspose 24.7 version, getting below error:
Aspose java.lang.IllegalAccessException: class com.aspose.words.internal.zzZSL cannot access class sun.print.Win32MediaTray (in module java.desktop) because module java.desktop does not export sun.print to unnamed module @30c0d731
Could you please help on this query.
Thanks,
Wafa
@wafasiddiqui
The error you are encountering, java.lang.IllegalAccessException: class com.aspose.words.internal.zzZSL cannot access class sun.print.Win32MediaTray
, suggests that there is an issue with module access in the Java environment you are using. This is likely due to the restrictions imposed by the Java Platform Module System (JPMS) introduced in Java 9.
To resolve this issue, you can try the following steps:
-
Add Module Exports: You can modify your Java command to include the necessary module exports. For example, you can add the following option when running your application:
--add-exports java.desktop/sun.print=ALL-UNNAMED
This command allows the unnamed module (your application) to access the sun.print
package.
-
Check Java Version: Ensure that you are using a compatible version of Java with Aspose.Words. If you are using a version higher than Java 8, consider testing with Java 8 to see if the issue persists.
-
Update Aspose.Words: If possible, consider updating to a newer version of Aspose.Words. There may have been fixes or improvements related to printing in later versions.
-
Consult Documentation: Review the Aspose.Words documentation for any specific notes regarding printing and compatibility with different Java versions. The documentation provides insights into setting up your environment and handling printing tasks effectively.
If these steps do not resolve the issue, you may want to reach out to Aspose support or check the community forums for additional assistance.
For more information on printing documents with Aspose.Words, you can refer to the official documentation here.
Sources:
[1]: Document Printing and Rendering | Aspose.Words Java Document Processing API
Hi Team,
We have used exports when running the jar using command line and it didn’t throw any error. But as we are calling the method of Java application from another external application, is there a way to add exports in the code instead of a command line?
Thanks,
Wafa
@wafasiddiqui I will consult with our Java developers and get back to you as soon as possible.
@wafasiddiqui,
In order for us to better understand this issue, please create a sample Java application (source code without compilation errors) that will help us reproduce your issue on our side and attach it here as a zip file for testing. Also, please attach sample files that can reproduce the issue.
Hi Alexey, we were able to use the first option and we are good with the solution. Thanks.
1 Like