Java Scaling image error class not found
Question
I'm trying to scale an image on Java. On a spike solution the following code works, nut when installing on the remote Linux server it gives me error 500.
Image scaledImage = img.getScaledInstance(scaledWidth, scaledHeight, Image.SCALE_SMOOTH);
I'm presented the following information:
java.lang.NoClassDefFoundError
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:164)
java.awt.Toolkit$2.run(Toolkit.java:821)
java.security.AccessController.doPrivileged(Native Method)
java.awt.Toolkit.getDefaultToolkit(Toolkit.java:804)
java.awt.Image.getScaledInstance(Image.java:158)
From what I've seen the might be need to setup a flag on Tomcat/Java concerning to the headless mode. Is there any other solution? If no, how show I setup that flag.
Thanks in advance!
Solution
Set the command line argument for headless mode of java:
-Djava.awt.headless=true
Look here for even more interesting solution (personally I don't like it): Setting java.awt.headless=true programmatically
Not sure but worth a try: make sure you have all the relevant libX** libraries. It may just use them without using X-Windows.