diff --git a/apps/systray/java/build.xml b/apps/systray/java/build.xml
index 4b909d80d..a7833441b 100644
--- a/apps/systray/java/build.xml
+++ b/apps/systray/java/build.xml
@@ -39,7 +39,7 @@
false if the given config file cannot be
+ * located or accessed, otherwise true
.
+ */
+ public boolean init(String configFile) {
_configFile = configFile;
- readConfigFile();
+ return readConfigFile();
}
public String getProperty(String key) {
@@ -43,7 +50,7 @@ public class ConfigFile {
writeConfigFile();
}
- private void readConfigFile() {
+ private boolean readConfigFile() {
FileInputStream fileInputStream = null;
@@ -51,16 +58,18 @@ public class ConfigFile {
fileInputStream = new FileInputStream(_configFile);
_properties.load(fileInputStream);
} catch (IOException e) {
- System.exit(1);
+ return false;
}
try {
fileInputStream.close();
} catch (IOException e1) {
// No worries.
}
+ return true;
}
private void writeConfigFile() {
+
FileOutputStream fileOutputStream = null;
try {
diff --git a/apps/systray/java/src/net/i2p/apps/systray/ShellCommand.java b/apps/systray/java/src/net/i2p/apps/systray/ShellCommand.java
index e3e8b64c1..d8f50d3f4 100644
--- a/apps/systray/java/src/net/i2p/apps/systray/ShellCommand.java
+++ b/apps/systray/java/src/net/i2p/apps/systray/ShellCommand.java
@@ -61,7 +61,6 @@ public class ShellCommand {
synchronized(caller) {
caller.notify(); // In case the caller is still in the wait() state.
}
- return;
}
}
@@ -184,7 +183,7 @@ public class ShellCommand {
* {@link #getErrorStream()}, respectively. Input can be passed to the
* STDIN
of the shell process via {@link #getInputStream()}.
*
- * @param _shellCommand The command for the shell to execute.
+ * @param shellCommand The command for the shell to execute.
*/
public void execute(String shellCommand) {
execute(shellCommand, NO_CONSUME_OUTPUT, NO_WAIT_FOR_EXIT_STATUS);
@@ -199,7 +198,7 @@ public class ShellCommand {
* Input can be passed to the STDIN
of the shell process via
* {@link #getInputStream()}.
*
- * @param _shellCommand The command for the shell to execute.
+ * @param shellCommand The command for the shell to execute.
* @return true
if the spawned shell process
* returns an exit status of 0 (indicating success),
* else false
.
@@ -221,7 +220,7 @@ public class ShellCommand {
* {@link #getErrorStream()}, respectively. Input can be passed to the
* STDIN
of the shell process via {@link #getInputStream()}.
*
- * @param _shellCommand The command for the shell to execute.
+ * @param shellCommand The command for the shell to execute.
* @param seconds The method will return true
if this
* number of seconds elapses without the process
* returning an exit status. A value of 0
@@ -256,7 +255,7 @@ public class ShellCommand {
* without waiting for an exit status. Any output produced by the executed
* command will not be displayed.
*
- * @param _shellCommand The command for the shell to execute.
+ * @param shellCommand The command for the shell to execute.
* @throws IOException
*/
public void executeSilent(String shellCommand) throws IOException {
@@ -268,7 +267,7 @@ public class ShellCommand {
* all of the command's resulting shell processes have completed. Any output
* produced by the executed command will not be displayed.
*
- * @param _shellCommand The command for the shell to execute.
+ * @param shellCommand The command for the shell to execute.
* @return true
if the spawned shell process
* returns an exit status of 0 (indicating success),
* else false
.
@@ -287,7 +286,7 @@ public class ShellCommand {
* specified number of seconds has elapsed first. Any output produced by the
* executed command will not be displayed.
*
- * @param _shellCommand The command for the shell to execute.
+ * @param shellCommand The command for the shell to execute.
* @param seconds The method will return true
if this
* number of seconds elapses without the process
* returning an exit status. A value of 0
@@ -356,7 +355,6 @@ public class ShellCommand {
processStdoutReader = new StreamReader(_inputStream);
processStdoutReader.start();
}
-
if (waitForExitStatus) {
try {
_process.waitFor();
@@ -374,7 +372,6 @@ public class ShellCommand {
if (_process.exitValue() > 0)
return false;
}
-
} catch (Exception e) {
return false;
}
diff --git a/apps/systray/java/src/net/i2p/apps/systray/SysTray.java b/apps/systray/java/src/net/i2p/apps/systray/SysTray.java
index ef15f9b56..a35f40ca8 100644
--- a/apps/systray/java/src/net/i2p/apps/systray/SysTray.java
+++ b/apps/systray/java/src/net/i2p/apps/systray/SysTray.java
@@ -25,7 +25,7 @@ public class SysTray implements SysTrayMenuListener {
private BrowserChooser _browserChooser;
private String _browserString;
- private ConfigFile _configFile = new ConfigFile("../systray.config");
+ private ConfigFile _configFile = new ConfigFile();
private Frame _frame;
private SysTrayMenuItem _itemExit = new SysTrayMenuItem("Exit I2P systray", "exit");
private SysTrayMenuItem _itemSelectBrowser = new SysTrayMenuItem("Select preferred browser...", "selectbrowser");
@@ -34,7 +34,12 @@ public class SysTray implements SysTrayMenuListener {
private UrlLauncher _urlLauncher = new UrlLauncher();
public SysTray() {
+
+ if (!_configFile.init("../systray.config"))
+ _configFile.setProperty("browser", "default");
+
_browserString = _configFile.getProperty("browser", "default");
+
_sysTrayMenuIcon.addSysTrayMenuListener(this);
createSysTrayMenu();
}