Fixed headless issue, added -8.
This commit is contained in:
@ -55,19 +55,14 @@ public class Main {
|
|||||||
* Main method launching the application.
|
* Main method launching the application.
|
||||||
*/
|
*/
|
||||||
public static void beginStartup(String[] args) {
|
public static void beginStartup(String[] args) {
|
||||||
boolean wasHeadless = Boolean.valueOf(System.getProperty("java.awt.headless")).booleanValue();
|
|
||||||
if(wasHeadless) {
|
|
||||||
System.setProperty("java.awt.headless", "false");
|
|
||||||
}
|
|
||||||
boolean headless_check = true;
|
|
||||||
try {
|
try {
|
||||||
// X permissions error is a java.lang.InternalError (a Throwable)
|
String headless = RouterManager.getRouterContext().getProperty("router.isHeadless");
|
||||||
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
boolean isHeadless = Boolean.parseBoolean(headless);
|
||||||
headless_check = ge.isHeadlessInstance();
|
if(isHeadless) {
|
||||||
} catch (Throwable t) {}
|
return;
|
||||||
if (wasHeadless)
|
}
|
||||||
System.setProperty("java.awt.headless", "true");
|
}
|
||||||
if (headless_check) {
|
catch(Exception e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package net.i2p.router.web;
|
package net.i2p.router.web;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.awt.GraphicsEnvironment;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FilenameFilter;
|
import java.io.FilenameFilter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -54,10 +55,51 @@ public class RouterConsoleRunner {
|
|||||||
private static final String DEFAULT_WEBAPPS_DIR = "./webapps/";
|
private static final String DEFAULT_WEBAPPS_DIR = "./webapps/";
|
||||||
private static final String USAGE = "Bad RouterConsoleRunner arguments, check clientApp.0.args in your clients.config file! " +
|
private static final String USAGE = "Bad RouterConsoleRunner arguments, check clientApp.0.args in your clients.config file! " +
|
||||||
"Usage: [[port host[,host]] [-s sslPort [host[,host]]] [webAppsDir]]";
|
"Usage: [[port host[,host]] [-s sslPort [host[,host]]] [webAppsDir]]";
|
||||||
|
private static final String PROP_HEADLESS = "router.isHeadless";
|
||||||
|
|
||||||
static {
|
static {
|
||||||
System.setProperty("org.mortbay.http.Version.paranoid", "true");
|
System.setProperty("org.mortbay.http.Version.paranoid", "true");
|
||||||
System.setProperty("java.awt.headless", "true");
|
|
||||||
|
//Check if we are in a headless environment, set properties accordingly
|
||||||
|
List<RouterContext> contexts = RouterContext.listContexts();
|
||||||
|
if(contexts != null && contexts.size() > 0) {
|
||||||
|
RouterContext context = contexts.get(0);
|
||||||
|
String headless = context.getProperty(PROP_HEADLESS);
|
||||||
|
if(headless == null) {
|
||||||
|
/*
|
||||||
|
* Let's check if we are in a headless environment.
|
||||||
|
* We do this by setting headless to false
|
||||||
|
* and trying to get the graphics environment.
|
||||||
|
* If this fails, we should be headless.
|
||||||
|
*/
|
||||||
|
System.setProperty("java.awt.headless", "false");
|
||||||
|
try {
|
||||||
|
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||||
|
ge.isHeadlessInstance();
|
||||||
|
context.setProperty(PROP_HEADLESS, "false");
|
||||||
|
}
|
||||||
|
catch(InternalError e) {
|
||||||
|
context.setProperty(PROP_HEADLESS, "true");
|
||||||
|
}
|
||||||
|
context.router().setConfigSetting(PROP_HEADLESS, context.getProperty(PROP_HEADLESS));
|
||||||
|
context.router().saveConfig();
|
||||||
|
context.router().shutdown(0);
|
||||||
|
}
|
||||||
|
boolean isHeadless = true;
|
||||||
|
try {
|
||||||
|
isHeadless = Boolean.parseBoolean(headless);
|
||||||
|
}
|
||||||
|
catch(Exception e) {
|
||||||
|
//Incorrect setting, let's choose headless for safety
|
||||||
|
isHeadless = true;
|
||||||
|
}
|
||||||
|
if(isHeadless) {
|
||||||
|
System.setProperty("java.awt.headless", "true");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.setProperty("java.awt.headless", "false");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -97,6 +97,7 @@
|
|||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="buildDesktopGui" depends="buildCore, buildrouter" >
|
<target name="buildDesktopGui" depends="buildCore, buildrouter" >
|
||||||
|
<ant dir="apps/desktopgui" target="clean" />
|
||||||
<ant dir="apps/desktopgui" target="jar" />
|
<ant dir="apps/desktopgui" target="jar" />
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
2011-02-11 Mathiasdm
|
||||||
|
* routerconsole: fixed graphs using jrobin; and headless issue
|
||||||
|
in general: no more switches between headless and non-headless.
|
||||||
|
|
||||||
2011-02-10 sponge
|
2011-02-10 sponge
|
||||||
* I2CP: fix NPE in QueuedClientConnectionRunner
|
* I2CP: fix NPE in QueuedClientConnectionRunner
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ public class RouterVersion {
|
|||||||
/** deprecated */
|
/** deprecated */
|
||||||
public final static String ID = "Monotone";
|
public final static String ID = "Monotone";
|
||||||
public final static String VERSION = CoreVersion.VERSION;
|
public final static String VERSION = CoreVersion.VERSION;
|
||||||
public final static long BUILD = 7;
|
public final static long BUILD = 8;
|
||||||
|
|
||||||
/** for example "-test" */
|
/** for example "-test" */
|
||||||
public final static String EXTRA = "";
|
public final static String EXTRA = "";
|
||||||
|
Reference in New Issue
Block a user