List of usage examples for java.awt GraphicsEnvironment isHeadless
public static boolean isHeadless()
From source file:org.solrsystem.Main.java
public static void main(String[] args) throws IOException, HttpException { if (GraphicsEnvironment.isHeadless()) { UI = new TextInstall(); } else {//from w w w. jav a 2 s . c o m UI = new GraphicalInstall(); } if (UI.confirm("Do you want to create ./SolrSystem in this directory and install SolrSystem?")) { File solrSystemDir = new File("SolrSystem"); //noinspection ResultOfMethodCallIgnored solrSystemDir.mkdir(); UI.downLoad(GRADLE); File file = new File(solrSystemDir, "gradle-1.11-bin.zip"); if (!file.exists()) { doGetToFile(GRADLE, file.getCanonicalPath(), UI); } } }
From source file:accinapdf.ACCinaPDF.java
/** * @param args the command line arguments *///from w ww . java2 s. c o m public static void main(String[] args) { controller.Logger.create(); controller.Bundle.getBundle(); if (GraphicsEnvironment.isHeadless()) { // Headless // Erro String fich; if (args.length != 1) { System.err.println(Bundle.getBundle().getString("invalidArgs")); return; } else { fich = args[0]; } try { System.out.println(Bundle.getBundle().getString("validating") + " " + fich); ArrayList<SignatureValidation> alSv = CCInstance.getInstance().validatePDF(fich, null); if (alSv.isEmpty()) { System.out.println(Bundle.getBundle().getString("notSigned")); } else { String newLine = System.getProperty("line.separator"); String toWrite = "("; int numSigs = alSv.size(); if (numSigs == 1) { toWrite += "1 " + Bundle.getBundle().getString("signature"); } else { toWrite += numSigs + " " + Bundle.getBundle().getString("signatures"); } toWrite += ")" + newLine; for (SignatureValidation sv : alSv) { toWrite += "\t" + sv.getName() + " - "; toWrite += (sv.isCertification() ? WordUtils.capitalize(Bundle.getBundle().getString("certificate")) : WordUtils.capitalize(Bundle.getBundle().getString("signed"))) + " " + Bundle.getBundle().getString("by") + " " + sv.getSignerName(); toWrite += newLine + "\t\t"; if (sv.isChanged()) { toWrite += Bundle.getBundle().getString("certifiedChangedOrCorrupted"); } else { if (sv.isCertification()) { if (sv.isValid()) { if (sv.isChanged() || !sv.isCoversEntireDocument()) { toWrite += Bundle.getBundle().getString("certifiedButChanged"); } else { toWrite += Bundle.getBundle().getString("certifiedOk"); } } else { toWrite += Bundle.getBundle().getString("changedAfterCertified"); } } else { if (sv.isValid()) { if (sv.isChanged()) { toWrite += Bundle.getBundle().getString("signedButChanged"); } else { toWrite += Bundle.getBundle().getString("signedOk"); } } else { toWrite += Bundle.getBundle().getString("signedChangedOrCorrupted"); } } } toWrite += newLine + "\t\t"; if (sv.getOcspCertificateStatus().equals(CertificateStatus.OK) || sv.getCrlCertificateStatus().equals(CertificateStatus.OK)) { toWrite += Bundle.getBundle().getString("certOK"); } else if (sv.getOcspCertificateStatus().equals(CertificateStatus.REVOKED) || sv.getCrlCertificateStatus().equals(CertificateStatus.REVOKED)) { toWrite += Bundle.getBundle().getString("certRevoked"); } else if (sv.getOcspCertificateStatus().equals(CertificateStatus.UNCHECKED) && sv.getCrlCertificateStatus().equals(CertificateStatus.UNCHECKED)) { toWrite += Bundle.getBundle().getString("certNotVerified"); } else if (sv.getOcspCertificateStatus().equals(CertificateStatus.UNCHAINED)) { toWrite += Bundle.getBundle().getString("certNotChained"); } else if (sv.getOcspCertificateStatus().equals(CertificateStatus.EXPIRED)) { toWrite += Bundle.getBundle().getString("certExpired"); } else if (sv.getOcspCertificateStatus().equals(CertificateStatus.CHAINED_LOCALLY)) { toWrite += Bundle.getBundle().getString("certChainedLocally"); } toWrite += newLine + "\t\t"; if (sv.isValidTimeStamp()) { toWrite += Bundle.getBundle().getString("validTimestamp"); } else { toWrite += Bundle.getBundle().getString("signerDateTime"); } toWrite += newLine + "\t\t"; toWrite += WordUtils.capitalize(Bundle.getBundle().getString("revision")) + ": " + sv.getRevision() + " " + Bundle.getBundle().getString("of") + " " + sv.getNumRevisions(); toWrite += newLine + "\t\t"; final DateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); final SimpleDateFormat sdf = new SimpleDateFormat("Z"); if (sv.getSignature().getTimeStampToken() == null) { Calendar cal = sv.getSignature().getSignDate(); String date = sdf.format(cal.getTime().toLocaleString()); toWrite += date + " " + sdf.format(cal.getTime()) + " (" + Bundle.getBundle().getString("signerDateTimeSmall") + ")"; } else { Calendar ts = sv.getSignature().getTimeStampDate(); String date = df.format(ts.getTime()); toWrite += Bundle.getBundle().getString("date") + " " + date + " " + sdf.format(ts.getTime()); } toWrite += newLine + "\t\t"; boolean ltv = (sv.getOcspCertificateStatus() == CertificateStatus.OK || sv.getCrlCertificateStatus() == CertificateStatus.OK); toWrite += Bundle.getBundle().getString("isLtv") + ": " + (ltv ? Bundle.getBundle().getString("yes") : Bundle.getBundle().getString("no")); String reason = sv.getSignature().getReason(); toWrite += newLine + "\t\t"; toWrite += Bundle.getBundle().getString("reason") + ": "; if (reason == null) { toWrite += Bundle.getBundle().getString("notDefined"); } else if (reason.isEmpty()) { toWrite += Bundle.getBundle().getString("notDefined"); } else { toWrite += reason; } String location = sv.getSignature().getLocation(); toWrite += newLine + "\t\t"; toWrite += Bundle.getBundle().getString("location") + ": "; if (location == null) { toWrite += Bundle.getBundle().getString("notDefined"); } else if (location.isEmpty()) { toWrite += Bundle.getBundle().getString("notDefined"); } else { toWrite += location; } toWrite += newLine + "\t\t"; toWrite += Bundle.getBundle().getString("allowsChanges") + ": "; try { int certLevel = CCInstance.getInstance().getCertificationLevel(sv.getFilename()); if (certLevel == PdfSignatureAppearance.CERTIFIED_FORM_FILLING) { toWrite += Bundle.getBundle().getString("onlyAnnotations"); } else if (certLevel == PdfSignatureAppearance.CERTIFIED_FORM_FILLING_AND_ANNOTATIONS) { toWrite += Bundle.getBundle().getString("annotationsFormFilling"); } else if (certLevel == PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED) { toWrite += Bundle.getBundle().getString("no"); } else { toWrite += Bundle.getBundle().getString("yes"); } } catch (IOException ex) { controller.Logger.getLogger().addEntry(ex); } toWrite += newLine + "\t\t"; if (sv.getOcspCertificateStatus() == CertificateStatus.OK || sv.getCrlCertificateStatus() == CertificateStatus.OK) { toWrite += (Bundle.getBundle().getString("validationCheck1") + " " + (sv.getOcspCertificateStatus() == CertificateStatus.OK ? Bundle.getBundle().getString("validationCheck2") + ": " + CCInstance.getInstance().getCertificateProperty( sv.getSignature().getOcsp().getCerts()[0].getSubject(), "CN") + " " + Bundle.getBundle().getString("at") + " " + df.format(sv.getSignature().getOcsp().getProducedAt()) : (sv.getCrlCertificateStatus() == CertificateStatus.OK ? "CRL" : "")) + (sv.getSignature().getTimeStampToken() != null ? Bundle.getBundle().getString("validationCheck3") + ": " + CCInstance.getInstance() .getCertificateProperty(sv.getSignature() .getTimeStampToken().getSID().getIssuer(), "O") : "")); } else if (sv.getSignature().getTimeStampToken() != null) { toWrite += (Bundle.getBundle().getString("validationCheck3") + ": " + CCInstance.getInstance().getCertificateProperty( sv.getSignature().getTimeStampToken().getSID().getIssuer(), "O")); } toWrite += newLine; } System.out.println(toWrite); System.out.println(Bundle.getBundle().getString("validationFinished")); } } catch (IOException | DocumentException | GeneralSecurityException ex) { System.err.println(Bundle.getBundle().getString("validationError")); Logger.getLogger(ACCinaPDF.class.getName()).log(Level.SEVERE, null, ex); } } else { // GUI CCSignatureSettings defaultSettings = new CCSignatureSettings(false); if (SystemUtils.IS_OS_WINDOWS) { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Windows".equals(info.getName())) { try { UIManager.setLookAndFeel(info.getClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { Logger.getLogger(ACCinaPDF.class.getName()).log(Level.SEVERE, null, ex); } break; } } } else if (SystemUtils.IS_OS_LINUX) { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { try { UIManager.setLookAndFeel(info.getClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { Logger.getLogger(ACCinaPDF.class.getName()).log(Level.SEVERE, null, ex); } break; } } } else if (SystemUtils.IS_OS_MAC_OSX) { try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.mac.MacLookAndFeel"); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { Logger.getLogger(ACCinaPDF.class.getName()).log(Level.SEVERE, null, ex); } } new SplashScreen().setVisible(true); } }
From source file:com.serotonin.m2m2.Main.java
/** * * @param args// w w w . j a v a 2 s . c om * @throws Exception */ public static void main(String[] args) throws Exception { Providers.add(ICoreLicense.class, new CoreLicenseDefinition()); Common.MA_HOME = System.getProperty("ma.home"); Common.M2M2_HOME = Common.MA_HOME; new File(Common.MA_HOME, "RESTART").delete(); Common.envProps = new ReloadingProperties("env"); openZipFiles(); ClassLoader moduleClassLoader = loadModules(); Lifecycle lifecycle = new Lifecycle(); Providers.add(ILifecycle.class, lifecycle); Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { ((ILifecycle) Providers.get(ILifecycle.class)).terminate(); } }); try { lifecycle.initialize(moduleClassLoader); if ((!GraphicsEnvironment.isHeadless()) && (Desktop.isDesktopSupported()) && (Common.envProps.getBoolean("web.openBrowserOnStartup"))) { Desktop.getDesktop().browse(new URI(new StringBuilder().append("http://localhost:") .append(Common.envProps.getInt("web.port", 8088)).toString())); } } catch (Exception e) { LOG.error("Error during initialization", e); lifecycle.terminate(); } }
From source file:io.github.eternalbits.compactvd.CompactVD.java
public static void main(String[] args) throws Exception { DiskImageJournal.scanDirectory(Static.getWorkingDirectory()); if (args.length == 0 && !GraphicsEnvironment.isHeadless()) { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); SwingUtilities.invokeLater(new Runnable() { @Override/*from w w w .j a v a 2s.c o m*/ public void run() { new FrontEnd(); } }); return; } new CompactVD().commandLine(args); }
From source file:ffx.Main.java
/** * Create an instance of Force Field X/*www.j a v a 2s. co m*/ * * @param args an array of {@link java.lang.String} objects. * @throws java.lang.Exception if any. */ public static void main(String[] args) throws Exception { /** * Process any "-D" command line flags. */ args = processProperties(args); /** * Configure our logging. */ startLogging(); /** * Print out help for the command line interface. */ if (GraphicsEnvironment.isHeadless() && args.length < 2) { commandLineInterfaceHelp(); } /** * Determine host name and process ID. */ environment(); /** * Start up the Parallel Java communication layer. */ startParallelJava(args); /** * Run the pKa input GUI if requested. Halts execution until GUI exits. */ /** * if (System.getProperty("pKaCalc") != null) { if * (System.getProperty("pKaCalc").equals("true")) { ffx.pka.pKaRun * runnable = new ffx.pka.pKaRun(); Thread t = new Thread(runnable,"pKa * Thread"); t.start(); t.join(); final int NUM_PKA_ARGS = 25; String[] * newArgs = new String[NUM_PKA_ARGS]; int currentArg = 0; for (int i=0; * i < newArgs.length; i++) { newArgs[currentArg] = runnable.getArg(i); * if (runnable.getArg(i) == null) { String temp = runnable.getArg(i - * 1); if (temp.startsWith("-s") || temp.startsWith("-f")) { * currentArg--; } } else { currentArg++; } } args = newArgs; } } */ // Print the header. // Moved this here so I could see the args being supplied by pKaRun. header(args); /** * Parse the specified command or structure file. */ File commandLineFile = null; int nArgs = args.length; if (nArgs > 0) { commandLineFile = new File(args[0]); // Resolve a relavtive path if (commandLineFile.exists()) { commandLineFile = new File(FilenameUtils.normalize(commandLineFile.getAbsolutePath())); } } /** * Convert the args to a List<String>. */ List<String> argList = new ArrayList<>(nArgs); if (nArgs > 1) { for (int i = 1; i < nArgs; i++) { argList.add(args[i]); } } /** * Start up the GUI or CLI version of Force Field X. */ if (!GraphicsEnvironment.isHeadless()) { startGraphicalUserInterface(commandLineFile, argList); } else { startCommandLineInterface(commandLineFile, argList); } }
From source file:info.magnolia.imaging.caching.CachingImageStreamerRepositoryTest.java
@Override @Before/*from w w w . ja v a 2s. c o m*/ public void setUp() throws Exception { // this used to set autostart to false, but I'm not sure why. // It seems fine as is. super.setUp(); // Now replace JcrSessionStrategy instances (current ctx and system ctx) with a wrapper than ensures we only save once, for the purpose of these tests. final MockContext systemContext = (MockContext) MgnlContext.getSystemContext(); systemContext.setRepositoryStrategy(new DelegatingSessionStrategy(systemContext.getRepositoryStrategy())); final MockContext regularContext = (MockContext) MgnlContext.getInstance(); regularContext.setRepositoryStrategy(new DelegatingSessionStrategy(regularContext.getRepositoryStrategy())); final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); if (!ge.isHeadless()) { log.warn("This test should run in headless mode as the server will likely run headless too!!!!!"); } }
From source file:Main.java
/** * checks the security permissions for accessing system clipboard * * for untrusted context (see isTrustedContext) checks the * permissions for the current event being handled * *///from w ww . j a v a 2s . c om public static boolean canAccessSystemClipboard() { boolean canAccess = false; if (!GraphicsEnvironment.isHeadless()) { SecurityManager sm = System.getSecurityManager(); if (sm == null) { canAccess = true; } else { try { sm.checkSystemClipboardAccess(); canAccess = true; } catch (SecurityException e) { } if (canAccess && !isTrustedContext()) { canAccess = canCurrentEventAccessSystemClipboard(true); } } } return canAccess; }
From source file:gov.vha.isaac.ochre.api.LookupService.java
/** * @return the {@link ServiceLocator} that is managing this ISAAC instance *///from ww w. ja v a2 s .c o m public static ServiceLocator get() { if (looker == null) { synchronized (lock) { if (looker == null) { if (GraphicsEnvironment.isHeadless()) { log.info("Installing headless toolkit"); HeadlessToolkit.installToolkit(); } PlatformImpl.startup(() -> { // No need to do anything here }); ArrayList<String> packagesToSearch = new ArrayList<>( Arrays.asList("gov.va", "gov.vha", "org.ihtsdo", "org.glassfish")); boolean readInhabitantFiles = Boolean .getBoolean(System.getProperty(Constants.READ_INHABITANT_FILES, "false")); if (System.getProperty(Constants.EXTRA_PACKAGES_TO_SEARCH) != null) { String[] extraPackagesToSearch = System.getProperty(Constants.EXTRA_PACKAGES_TO_SEARCH) .split(";"); packagesToSearch.addAll(Arrays.asList(extraPackagesToSearch)); } try { String[] packages = packagesToSearch.toArray(new String[] {}); log.info("Looking for HK2 annotations " + (readInhabitantFiles ? "from inhabitant files" : "skipping inhabitant files") + "; and scanning in the packages: " + Arrays.toString(packages)); looker = HK2RuntimeInitializer.init("ISAAC", readInhabitantFiles, packages); log.info("HK2 initialized. Identifed " + looker.getAllServiceHandles((criteria) -> { return true; }).size() + " services"); } catch (Exception e) { throw new RuntimeException(e); } } } } return looker; }
From source file:de.tudarmstadt.ukp.clarin.webanno.webapp.standalone.StandaloneShutdownDialog.java
private void displayShutdownDialog() { String serverId = ServerDetector.getServerId(); log.info("Running in: " + (serverId != null ? serverId : "unknown server")); log.info("Console: " + ((System.console() != null) ? "available" : "not available")); log.info("Headless: " + (GraphicsEnvironment.isHeadless() ? "yes" : "no")); // Show this only when run from the standalone JAR via a double-click if (System.console() == null && !GraphicsEnvironment.isHeadless() && ServerDetector.isWinstone()) { log.info("If you are running WebAnno in a server environment, please use '-Djava.awt.headless=true'"); EventQueue.invokeLater(new Runnable() { @Override/* w w w . jav a2 s . c o m*/ public void run() { final JOptionPane optionPane = new JOptionPane(new JLabel( "<HTML>WebAnno is running now and can be accessed via <a href=\"http://localhost:8080\">http://localhost:8080</a>.<br>" + "WebAnno works best with the browsers Google Chrome or Safari.<br>" + "Use this dialog to shut WebAnno down.</HTML>"), JOptionPane.INFORMATION_MESSAGE, JOptionPane.OK_OPTION, null, new String[] { "Shutdown" }); final JDialog dialog = new JDialog((JFrame) null, "WebAnno", true); dialog.setContentPane(optionPane); dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); dialog.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent we) { // Avoid closing window by other means than button } }); optionPane.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent aEvt) { if (dialog.isVisible() && (aEvt.getSource() == optionPane) && (aEvt.getPropertyName().equals(JOptionPane.VALUE_PROPERTY))) { System.exit(0); } } }); dialog.pack(); dialog.setVisible(true); } }); } else { log.info("Running in server environment or from command line: disabling interactive shutdown dialog."); } }
From source file:com.github.cmisbox.ui.UI.java
private UI() { this.log = LogFactory.getLog(this.getClass()); try {// www . j a v a 2s . c o m this.available = !GraphicsEnvironment.isHeadless(); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); if (SystemTray.isSupported()) { this.tray = SystemTray.getSystemTray(); Image image = ImageIO.read(this.getClass().getResource("images/cmisbox.png")); ActionListener exitListener = new ActionListener() { public void actionPerformed(ActionEvent e) { Main.exit(0); } }; this.popup = new PopupMenu(); MenuItem defaultItem = new MenuItem(Messages.exit); defaultItem.addActionListener(exitListener); this.popup.add(defaultItem); MenuItem loginItem = new MenuItem(Messages.login); loginItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { new LoginDialog(); } }); this.popup.add(loginItem); MenuItem treeItem = new MenuItem(Messages.showTree); treeItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { new TreeSelect(); } }); this.popup.add(treeItem); final TrayIcon trayIcon = new TrayIcon(image, UI.NOTIFY_TITLE, this.popup); trayIcon.setImageAutoSize(true); this.tray.add(trayIcon); this.notify(Messages.startupComplete); } } catch (Exception e) { this.log.error(e); } }