com.threerings.getdown.util
Class LaunchUtil

java.lang.Object
  extended by com.threerings.getdown.util.LaunchUtil

public class LaunchUtil
extends Object

Useful routines for launching Java applications from within other Java applications.


Field Summary
static String LOCAL_JAVA_DIR
          The directory into which a local VM installation should be unpacked.
 
Constructor Summary
LaunchUtil()
           
 
Method Summary
static String getJVMPath(File appdir)
          Reconstructs the path to the JVM used to launch this process.
static String getJVMPath(File appdir, boolean windebug)
          Reconstructs the path to the JVM used to launch this process.
static boolean mustMonitorChildren()
          Returns true if, on this operating system, we have to stick around and read the stderr from our children processes to prevent them from filling their output buffers and hanging.
static boolean updateVersionAndRelaunch(File appdir, String getdownJarName, String newVersion)
          Writes a version.txt file into the specified application directory and attempts to relaunch Getdown in that directory which will cause it to upgrade to the newly specified version and relaunch the application.
static void upgradeGetdown(File oldgd, File curgd, File newgd)
          Upgrades Getdown by moving an installation managed copy of the Getdown jar file over the non-managed copy (which would be used to run Getdown itself).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCAL_JAVA_DIR

public static final String LOCAL_JAVA_DIR
The directory into which a local VM installation should be unpacked.

See Also:
Constant Field Values
Constructor Detail

LaunchUtil

public LaunchUtil()
Method Detail

updateVersionAndRelaunch

public static boolean updateVersionAndRelaunch(File appdir,
                                               String getdownJarName,
                                               String newVersion)
                                        throws IOException
Writes a version.txt file into the specified application directory and attempts to relaunch Getdown in that directory which will cause it to upgrade to the newly specified version and relaunch the application.

Parameters:
appdir - the directory in which the application is installed.
getdownJarName - the name of the getdown jar file in the application directory. This is probably getdown-pro.jar or getdown-retro-pro.jar if you are using the results of the standard build.
newVersion - the new version to which Getdown will update when it is executed.
Returns:
true if the relaunch succeeded, false if we were unable to relaunch due to being on Windows 9x where we cannot launch subprocesses without waiting around for them to exit, reading their stdout and stderr all the while. If true is returned, the application may exit after making this call as it will be upgraded and restarted. If false is returned, the application should tell the user that they must restart the application manually.
Throws:
IOException - thrown if we were unable to create the version.txt file in the supplied application directory. If the version.txt file cannot be created, restarting Getdown will not cause the application to be upgraded, so the application will have to resort to telling the user that it is in a bad way.

getJVMPath

public static String getJVMPath(File appdir)
Reconstructs the path to the JVM used to launch this process.


getJVMPath

public static String getJVMPath(File appdir,
                                boolean windebug)
Reconstructs the path to the JVM used to launch this process.

Parameters:
windebug - if true we will use java.exe instead of javaw.exe on Windows.

upgradeGetdown

public static void upgradeGetdown(File oldgd,
                                  File curgd,
                                  File newgd)
Upgrades Getdown by moving an installation managed copy of the Getdown jar file over the non-managed copy (which would be used to run Getdown itself).

If the upgrade fails for a variety of reasons, warnings are logged but no other actions are taken. There's not much else one can do other than try again next time around.


mustMonitorChildren

public static boolean mustMonitorChildren()
Returns true if, on this operating system, we have to stick around and read the stderr from our children processes to prevent them from filling their output buffers and hanging.



Copyright © 2013. All Rights Reserved.