Revision: 2981 http://vexi.svn.sourceforge.net/vexi/?rev=2981&view=rev Author: mkpg2 Date: 2008-07-21 14:43:25 +0000 (Mon, 21 Jul 2008)
Log Message: ----------- Fix. getenv workaround for java 1.4 Modified Paths: -------------- trunk/launch/org.vexi.launch/src/org/vexi/launcher/Launcher.java Modified: trunk/launch/org.vexi.launch/src/org/vexi/launcher/Launcher.java =================================================================== --- trunk/launch/org.vexi.launch/src/org/vexi/launcher/Launcher.java 2008-07-21 14:23:38 UTC (rev 2980) +++ trunk/launch/org.vexi.launch/src/org/vexi/launcher/Launcher.java 2008-07-21 14:43:25 UTC (rev 2981) @@ -27,7 +27,33 @@ static private String getEnv(String name) { - return System.getenv(name); + try{ + return System.getenv(name); + }catch(Throwable t){ + // REMARK - they deprecated this in 1.4, only to bring it back in 1.5. + // By deprecated we mean it throws an error. So here we fall back to + // getting it from the commandline. + try { + String os = System.getProperty("os.name").toLowerCase(); + Process p; + String cmd; + if (os.indexOf("windows 9") != -1 || os.indexOf("windows me") != -1) { + cmd = "command.com /c set"; + } else if (os.indexOf("windows") > -1) { + cmd = "cmd.exe /c set"; + } else { + cmd = "env"; + } + p = Runtime.getRuntime().exec(cmd); + BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); + String s; + while ((s = br.readLine()) != null) + if (s.startsWith(name + "=")) + return s.substring(name.length() + 1); + } catch (Exception e) { + } + return null; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn