Servlet giving error java.lang.NoClassDefFoundError

前端 未结 2 1130
滥情空心
滥情空心 2021-01-01 08:16

I am using the following code in a servlet of my app

java.awt.Image awtImg = java.awt.Toolkit.getDefaultToolkit().createImage(str1);

When I run

2条回答
  •  难免孤独
    2021-01-01 08:32

    To use AWT classes in a server side application, I believe you need to run in "headless" mode. Change your servlet container's startup to include:

    -Djava.awt.headless=true
    

    (Or set the system property within your own code if you really have to.)

    You might also want to consider using an alternative imaging library - either a third-party one or the javax.imageio package.

提交回复
热议问题