Commit 0e4e613d authored by Derek DeMoro's avatar Derek DeMoro Committed by derek

Launcher now works with startup.jar


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@252 b35dd754-fafc-0310-a699-88a17e54d16e
parent cea4de90
...@@ -88,7 +88,7 @@ public class Launcher { ...@@ -88,7 +88,7 @@ public class Launcher {
toolbar.add(stopButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); toolbar.add(stopButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
toolbar.add(browserButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); toolbar.add(browserButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
toolbar.add(quitButton, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); toolbar.add(quitButton, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
if (splashLabel != null) { if (splashLabel != null) {
mainPanel.add(splashLabel, BorderLayout.CENTER); mainPanel.add(splashLabel, BorderLayout.CENTER);
} }
...@@ -163,43 +163,41 @@ public class Launcher { ...@@ -163,43 +163,41 @@ public class Launcher {
private synchronized void startApplication() { private synchronized void startApplication() {
if (messengerd == null) { if (messengerd == null) {
File binDir = null;
File libDir = null; File libDir = null;
File homeDir = null;
File exe = null; File exe = null;
try { try {
// Aliases keep their cwd rather than the aliased libDir's cwd on MacOS X // Aliases keep their cwd rather than the aliased binDir's cwd on MacOS X
// so we'll do a search for messengerd rather than relying on it being where // so we'll do a search for messengerd rather than relying on it being where
// we think it will be... // we think it will be...
libDir = new File("").getAbsoluteFile(); binDir = new File("").getAbsoluteFile();
libDir = new File("../lib").getAbsoluteFile();
homeDir = binDir.getParentFile();
File parentDir = libDir.getParentFile();
if ("lib".equals(libDir.getName())) { if (libDir.exists()) {
// Windows messengerd = Runtime.getRuntime().exec(new String[]{"java", "-jar", new File(libDir, "startup.jar").toString()});
exe = new File(parentDir, "messenger.exe"); }
else {
// MacOS X
exe = new File(homeDir, "messenger.app");
if (exe.exists()) { if (exe.exists()) {
messengerd = Runtime.getRuntime().exec(new String[]{exe.toString()}); messengerd = Runtime.getRuntime().exec(new String[]{
"open", exe.toString()
});
} }
else { else {
// MacOS X // Unix
exe = new File(parentDir, "messenger.app"); exe = new File(homeDir, "messenger");
if (exe.exists()) { if (exe.exists()) {
messengerd = Runtime.getRuntime().exec(new String[]{ messengerd = Runtime.getRuntime().exec(new String[]{exe.toString()});
"open", exe.toString()
});
} }
else { else {
// Unix throw new FileNotFoundException();
exe = new File(parentDir, "messenger");
if (exe.exists()) {
messengerd = Runtime.getRuntime().exec(new String[]{exe.toString()});
}
else {
throw new FileNotFoundException();
}
} }
} }
} }
...@@ -207,7 +205,7 @@ public class Launcher { ...@@ -207,7 +205,7 @@ public class Launcher {
catch (Exception e) { catch (Exception e) {
// Try one more time using the jar and hope java is on the path // Try one more time using the jar and hope java is on the path
try { try {
if (libDir != null) { if (binDir != null) {
messengerd = Runtime.getRuntime().exec(new String[]{ messengerd = Runtime.getRuntime().exec(new String[]{
"java", "-jar", new File(libDir, "startup.jar").toString() "java", "-jar", new File(libDir, "startup.jar").toString()
}); });
...@@ -250,7 +248,7 @@ public class Launcher { ...@@ -250,7 +248,7 @@ public class Launcher {
BrowserLauncher.openURL("http://127.0.0.1:" + port + "/index.html"); BrowserLauncher.openURL("http://127.0.0.1:" + port + "/index.html");
} }
catch (Exception e) { catch (Exception e) {
e.printStackTrace(); JOptionPane.showMessageDialog(new JFrame(), configFile + " " + e.getMessage());
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment