summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--java/src/IceGridGUI/Fallback.java77
1 files changed, 76 insertions, 1 deletions
diff --git a/java/src/IceGridGUI/Fallback.java b/java/src/IceGridGUI/Fallback.java
index 343b0a5f3e2..f5198e1db7e 100644
--- a/java/src/IceGridGUI/Fallback.java
+++ b/java/src/IceGridGUI/Fallback.java
@@ -9,10 +9,85 @@
package IceGridGUI;
+import javax.swing.JOptionPane;
+
public class Fallback extends javax.swing.JApplet
{
public void start()
{
- IceGridGUI.Main.main(MainProxy.args());
+ try
+ {
+ java.net.URL jar = Fallback.class.getProtectionDomain().getCodeSource().getLocation();
+
+ java.util.List<String> command = new java.util.ArrayList<String>();
+ command.add("java");
+ command.add("IceGridGUI.Main");
+ String[] args = MainProxy.args();
+ for(String arg : args)
+ {
+ command.add(arg);
+ }
+ ProcessBuilder pb = new ProcessBuilder(command);
+
+ pb.redirectOutput(ProcessBuilder.Redirect.INHERIT);
+ pb.redirectError(ProcessBuilder.Redirect.INHERIT);
+
+ java.util.Map<String, String> env = pb.environment();
+
+ String classPath = env.get("CLASSPATH");
+ classPath = classPath == null ? "" : classPath;
+
+ if(classPath.indexOf("IceGridGUI.jar") == -1)
+ {
+ if(classPath == "")
+ {
+ classPath = jar.getPath();
+ }
+ else
+ {
+ classPath = System.getProperty("path.separator") + jar.getPath();
+ }
+ env.put("CLASSPATH", classPath);
+ }
+
+ final Process p = pb.start();
+ if(p != null)
+ {
+ Runtime.getRuntime().addShutdownHook(new Thread()
+ {
+ public void run()
+ {
+ while(true)
+ {
+ try
+ {
+ p.waitFor();
+ break;
+ }
+ catch(InterruptedException ex)
+ {
+ }
+ }
+ }
+ });
+ }
+
+ //
+ // Exit from the JApplet after we have lauch IceGridGUI
+ //
+ System.exit(0);
+ }
+ catch(java.io.IOException ex)
+ {
+ ex.printStackTrace();
+ JOptionPane.showMessageDialog(null,
+ "IOException trying to start IceGrid Admin from Fallback class",
+ "IceGrid Admin Error",
+ JOptionPane.ERROR_MESSAGE);
+ //
+ // Exit from the JApplet after we have lauch IceGridGUI
+ //
+ System.exit(1);
+ }
}
} \ No newline at end of file