AWT libraries using Java 1.6 on Linux Server in a datacenter
I need to create and store thumbnails (of images from the web) and store them on the server. Can I use the awt libraries (as listed below) on a linux server running in a datacenter (without a monitor)? I do not know if the server has a graphics card or needs one for these libraries to work...
import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.Graphics2D; import java.awt.geom.AffineTransform; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException开发者_StackOverflow中文版; import java.io.OutputStream; import java.io.FileOutputStream; import java.net.URL; import javax.imageio.ImageIO; import org.springframework.stereotype.Service; import com.sun.image.codec.jpeg.ImageFormatException; import com.sun.image.codec.jpeg.JPEGCodec; import com.sun.image.codec.jpeg.JPEGImageEncoder; import java.awt.Color;
You can as long as you run java in headless mode:
java -Djava.awt.headless=true your.MainClass
精彩评论