GP-6399 Ensure we are not in headless mode for GUI launch. Headless apps should use headless config.

This commit is contained in:
ghidra1
2026-02-04 15:46:27 -05:00
parent dc49565866
commit 050f7159ad
2 changed files with 19 additions and 7 deletions
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -27,7 +27,7 @@ import ghidra.GhidraApplicationLayout;
import ghidra.GhidraTestApplicationLayout;
import ghidra.base.project.GhidraProject;
import ghidra.framework.Application;
import ghidra.framework.GhidraApplicationConfiguration;
import ghidra.framework.HeadlessGhidraApplicationConfiguration;
import ghidra.framework.data.OpenMode;
import ghidra.framework.model.DomainFile;
import ghidra.framework.model.ProjectData;
@@ -163,8 +163,8 @@ public class IsfServer extends Thread {
public static void main(String[] args) throws FileNotFoundException, IOException {
GhidraApplicationLayout layout =
new GhidraTestApplicationLayout(new File(AbstractGTest.getTestDirectoryPath()));
GhidraApplicationConfiguration config = new GhidraApplicationConfiguration();
config.setShowSplashScreen(false);
HeadlessGhidraApplicationConfiguration config =
new HeadlessGhidraApplicationConfiguration();
Application.initializeApplication(layout, config);
IsfServer server = new IsfServer(null, 54321);
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,6 +15,8 @@
*/
package ghidra.framework;
import java.awt.GraphicsEnvironment;
import docking.DockingErrorDisplay;
import docking.DockingWindowManager;
import docking.framework.ApplicationInformationDisplayFactory;
@@ -37,6 +39,16 @@ public class GhidraApplicationConfiguration extends HeadlessGhidraApplicationCon
private static final String USER_AGREEMENT_PROPERTY_NAME = "USER_AGREEMENT";
private boolean showSplashScreen = true;
public GhidraApplicationConfiguration() {
if (GraphicsEnvironment.isHeadless()) {
System.err.println(
"ERROR: Unable to launch Ghidra GUI application in headless environment.");
System.err.println(
"If launching from a remote SSH shell, you must have an X11 compatible client with X11 forwarding enabled.");
System.exit(1);
}
}
@Override
public boolean isHeadless() {
return false;