Let Tomcat under Linux (JDK1.4, Tomcat 4.0 or later)
Copyright Notice: 9CBS is this BLOG managed service provider. If this paper involves copyright issues, 9CBS does not assume relevant responsibilities, please contact the copyright owner directly with the article Author.
1. Steps:
Modify $ catalina_home / bin / catalina.sh file ($ CATALINA_HOME refers to the Tomcat installation directory), in the original files of 164, 172, 189, 196, 213, 225, add a line of new lines as follows
-Djava.awt.Headless = True /
The deployment is complete. Very simple :))))
2. Test:
2.1 establish a directory
CD / usr / local / Tomcat / WebApps /
Mkdir -P testimage / web-inf / classes
2.2 Write index.jsp
Built index.jsp in / usr / local / tomcat / webapps / testimage directory, the content is as follows:
<% @ page import = "java.awt. *; java.awt.image. *; java.io. *; com.sun.Image.codec.jpeg. *;"%> <% bufferedimage bi = new bufferedimage 200, 100, BufferedImage.TYPE_INT_RGB); Graphics g = bi.getGraphics (); g.drawString ( "test java image", 0, 45); FileOutputStream fos = new FileOutputStream (application.getRealPath ( "/") "test .jpg "); JPEGIMAGEENCODER JPEGIE = JPEGCODEC.CREATEJPEGENCODER (FOS); JPEGIE.Encode (bi); fos.close ();%>
2.3 operation
Start Tomcat, open your browser, enter:
Http: // localhost: 8080 / testimage
3. Postscript
3.1 Solutions flowing online, most to install XVFB, and then specify the system default x server as XVFB. But I use this method, the X Window comes into the system. Solving this additional question is very hard, I have no strength to study, I know that friends can reply below this document, thank you.
3.2 Some people have mentioned the headless support, but always say that the headless support is invalid in the Java original file, because Tomcat does not support no headless support. But why didn't they think of the headless support when Tomcat started? Well, 874 These people also went to the guys.