Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi;
To retrieve your environment variable use the following into a tJava (begin of your Job) like this : context.MyPath = System.getProperty("SYSTEM_ENV");
Best regards;
Hi;
To retrieve your environment variable use the following into a tJava (begin of your Job) like this : context.MyPath = System.getProperty("SYSTEM_ENV");
Best regards;
// template routine Java
package routines;
import java.io.*;
import java.util.*;
public class getEnv {
static String value = null;
public static String getEnvValue(String key) {
try {
Properties p = getEnv.getEnvVars();
value = p.getProperty(key);
} catch (Throwable e) {
e.printStackTrace();
}
return value;
}
public static Properties getEnvVars() throws Throwable {
Process p = null;
Properties envVars = new Properties();
Runtime r = Runtime.getRuntime();
String OS = System.getProperty("os.name").toLowerCase();
if (OS.indexOf("windows 9") > -1) {
p = r.exec("command.com /c set");
} else if ((OS.indexOf("nt") > -1) || (OS.indexOf("windows 2000") > -1)
|| (OS.indexOf("windows xp") > -1)) {
p = r.exec("cmd.exe /c set");
} else {
// it is Unix os.
p = r.exec("env");
}
BufferedReader br = new BufferedReader(new InputStreamReader(p
.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
int idx = line.indexOf('=');
String key = line.substring(0, idx);
String value = line.substring(idx + 1);
envVars.setProperty(key, value);
}
return envVars;
}
}
Hello Dave
Please use the following routine, it both works on windows and Unix/Linux.// template routine Java
package routines;
import java.io.*;
import java.util.*;
public class getEnv {
static String value = null;
public static String getEnvValue(String key) {
try {
Properties p = getEnv.getEnvVars();
value = p.getProperty(key);
} catch (Throwable e) {
e.printStackTrace();
}
return value;
}
public static Properties getEnvVars() throws Throwable {
Process p = null;
Properties envVars = new Properties();
Runtime r = Runtime.getRuntime();
String OS = System.getProperty("os.name").toLowerCase();
if (OS.indexOf("windows 9") > -1) {
p = r.exec("command.com /c set");
} else if ((OS.indexOf("nt") > -1) || (OS.indexOf("windows 2000") > -1)
|| (OS.indexOf("windows xp") > -1)) {
p = r.exec("cmd.exe /c set");
} else {
// it is Unix os.
p = r.exec("env");
}
BufferedReader br = new BufferedReader(new InputStreamReader(p
.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
int idx = line.indexOf('=');
String key = line.substring(0, idx);
String value = line.substring(idx + 1);
envVars.setProperty(key, value);
}
return envVars;
}
}
Best regards
shong
Hello Dave
Please use the following routine, it both works on windows and Unix/Linux.// template routine Java
package routines;
import java.io.*;
import java.util.*;
public class getEnv {
static String value = null;
public static String getEnvValue(String key) {
try {
Properties p = getEnv.getEnvVars();
value = p.getProperty(key);
} catch (Throwable e) {
e.printStackTrace();
}
return value;
}
public static Properties getEnvVars() throws Throwable {
Process p = null;
Properties envVars = new Properties();
Runtime r = Runtime.getRuntime();
String OS = System.getProperty("os.name").toLowerCase();
if (OS.indexOf("windows 9") > -1) {
p = r.exec("command.com /c set");
} else if ((OS.indexOf("nt") > -1) || (OS.indexOf("windows 2000") > -1)
|| (OS.indexOf("windows xp") > -1)) {
p = r.exec("cmd.exe /c set");
} else {
// it is Unix os.
p = r.exec("env");
}
BufferedReader br = new BufferedReader(new InputStreamReader(p
.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
int idx = line.indexOf('=');
String key = line.substring(0, idx);
String value = line.substring(idx + 1);
envVars.setProperty(key, value);
}
return envVars;
}
}
Best regards
shong