Java tutorial
import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.HeadlessException; public class Main { public static void main(String[] argv) throws Exception { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); try { GraphicsDevice[] gs = ge.getScreenDevices(); int numScreens = gs.length; } catch (HeadlessException e) { } } }