Java tutorial
//package com.java2s; /* * Copyright 2001-2008 Aqris Software AS. All rights reserved. * * This program is dual-licensed under both the Common Development * and Distribution License ("CDDL") and the GNU General Public * License ("GPL"). You may elect to use one or the other of these * licenses. */ import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; public class Main { /** * Check whether GUI present or not. */ public static boolean isGUI() { boolean retVal = false; try { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gs = ge.getScreenDevices(); if (gs.length > 0) { retVal = true; } } catch (Throwable t) { } return retVal; } }