List of usage examples for java.lang System getenv
public static java.util.Map<String, String> getenv()
From source file:Main.java
public static void main(String[] args) throws Exception { System.out.println(System.getenv()); }
From source file:Main.java
public static void main(String[] args) { Map map = System.getenv(); Set keys = map.keySet();//from ww w . j a v a 2 s.com Iterator iterator = keys.iterator(); while (iterator.hasNext()) { String key = (String) iterator.next(); String value = (String) map.get(key); System.out.println(key + " = " + value); } }
From source file:com.everis.storage.Application.java
public static void main(String[] args) throws Exception { System.out.println("ENV:" + System.getenv()); Thread.sleep(5000);/*w w w . jav a2 s .com*/ ApplicationContext ctx = SpringApplication.run(Application.class, args); /* for(String bean : ctx.getBeanDefinitionNames()) { System.out.println("Bean:" + bean); }*/ }
From source file:com.fizzed.stork.test.HelloMain.java
static public void main(String[] args) throws Exception { ObjectMapper mapper = new ObjectMapper(); mapper.configure(SerializationFeature.INDENT_OUTPUT, true); HelloOutput output = new HelloOutput(); output.setConfirm("Hello World!"); output.setEnvironment(System.getenv()); output.setSystemProperties(System.getProperties()); output.setArguments(Arrays.asList(args)); mapper.writeValue(System.out, output); }
From source file:eu.stratosphere.yarn.YarnTaskManagerRunner.java
public static void main(final String[] args) throws IOException { Map<String, String> envs = System.getenv(); final String yarnClientUsername = envs.get(Client.ENV_CLIENT_USERNAME); final String localDirs = envs.get(Environment.LOCAL_DIRS.key()); // configure local directory final String[] newArgs = Arrays.copyOf(args, args.length + 2); newArgs[newArgs.length - 2] = "-" + TaskManager.ARG_CONF_DIR; newArgs[newArgs.length - 1] = localDirs; LOG.info("Setting log path " + localDirs); LOG.info("YARN daemon runs as '" + UserGroupInformation.getCurrentUser().getShortUserName() + "' setting" + " user to execute Stratosphere TaskManager to '" + yarnClientUsername + "'"); UserGroupInformation ugi = UserGroupInformation.createRemoteUser(yarnClientUsername); for (Token<? extends TokenIdentifier> toks : UserGroupInformation.getCurrentUser().getTokens()) { ugi.addToken(toks);/*from www . j ava 2s .co m*/ } ugi.doAs(new PrivilegedAction<Object>() { @Override public Object run() { try { TaskManager.main(newArgs); } catch (Exception e) { e.printStackTrace(); } return null; } }); }
From source file:com.todo.backend.BackendApplication.java
public static void main(String[] args) { final SpringApplication app = new SpringApplication(BackendApplication.class); final SimpleCommandLinePropertySource source = new SimpleCommandLinePropertySource(args); if (!source.containsProperty("spring.profiles.active") && !System.getenv().containsKey("SPRING_PROFILES_ACTIVE")) { app.setAdditionalProfiles("dev"); }//w w w. java 2 s . co m app.run(args).getEnvironment(); }
From source file:com.datatorrent.stram.StreamingAppMaster.java
/** * @param args/*from w ww.j ava2s .com*/ * Command line args * @throws Throwable */ public static void main(final String[] args) throws Throwable { StdOutErrLog.tieSystemOutAndErrToLog(); LOG.info("Master starting with classpath: {}", System.getProperty("java.class.path")); LOG.info("version: {}", VersionInfo.APEX_VERSION.getBuildVersion()); StringWriter sw = new StringWriter(); for (Map.Entry<String, String> e : System.getenv().entrySet()) { sw.append("\n").append(e.getKey()).append("=").append(e.getValue()); } LOG.info("appmaster env:" + sw.toString()); Options opts = new Options(); opts.addOption("app_attempt_id", true, "App Attempt ID. Not to be used unless for testing purposes"); opts.addOption("help", false, "Print usage"); CommandLine cliParser = new GnuParser().parse(opts, args); // option "help" overrides and cancels any run if (cliParser.hasOption("help")) { new HelpFormatter().printHelp("ApplicationMaster", opts); return; } Map<String, String> envs = System.getenv(); ApplicationAttemptId appAttemptID = Records.newRecord(ApplicationAttemptId.class); if (!envs.containsKey(Environment.CONTAINER_ID.name())) { if (cliParser.hasOption("app_attempt_id")) { String appIdStr = cliParser.getOptionValue("app_attempt_id", ""); appAttemptID = ConverterUtils.toApplicationAttemptId(appIdStr); } else { throw new IllegalArgumentException("Application Attempt Id not set in the environment"); } } else { ContainerId containerId = ConverterUtils.toContainerId(envs.get(Environment.CONTAINER_ID.name())); appAttemptID = containerId.getApplicationAttemptId(); } boolean result = false; StreamingAppMasterService appMaster = null; try { appMaster = new StreamingAppMasterService(appAttemptID); LOG.info("Initializing Application Master."); Configuration conf = new YarnConfiguration(); appMaster.init(conf); appMaster.start(); result = appMaster.run(); } catch (Throwable t) { LOG.error("Exiting Application Master", t); System.exit(1); } finally { if (appMaster != null) { appMaster.stop(); } } if (result) { LOG.info("Application Master completed."); System.exit(0); } else { LOG.info("Application Master failed."); System.exit(2); } }
From source file:com.asakusafw.bulkloader.cache.DeleteCacheStorageRemote.java
/** * Program entry for normal launching (see class documentation). * @param args program arguments/*from ww w .j a v a 2s . com*/ * @throws Exception if failed to execute */ public static void main(String[] args) throws Exception { SystemOutManager.changeSystemOutToSystemErr(); RuntimeContext.set(RuntimeContext.DEFAULT.apply(System.getenv())); DeleteCacheStorageRemote service = new DeleteCacheStorageRemote(); service.setConf(new Configuration()); int exitCode = service.run(args); System.exit(exitCode); }
From source file:com.asakusafw.bulkloader.cache.GetCacheInfoRemote.java
/** * Program entry for normal launching (see class documentation). * @param args program arguments/*from www.j a v a 2 s . c om*/ * @throws Exception if failed to execute */ public static void main(String[] args) throws Exception { SystemOutManager.changeSystemOutToSystemErr(); RuntimeContext.set(RuntimeContext.DEFAULT.apply(System.getenv())); GetCacheInfoRemote service = new GetCacheInfoRemote(); service.setConf(new Configuration()); int exitCode = service.run(args); System.exit(exitCode); }
From source file:org.atomspace.pi2c.runtime.Server.java
public static void main(String[] args) throws Exception { System.err.println("::: ----------------------------------------------------------------------- :::"); System.err.println("::: ------------------------------ STARTING ------------------------------:::"); System.err.println("::: ----------------------------------------------------------------------- :::"); System.err.println("\n::: SYSTEM-Properties: :::"); Set<?> properties = System.getProperties().keySet(); for (Object object : properties) { System.err.println("::: " + object.toString() + " = " + System.getProperty(object.toString())); }/* ww w .j a v a2s. c om*/ System.err.println("\n::: ENV-Properties: :::"); properties = System.getenv().keySet(); for (Object object : properties) { System.err.println("::: " + object.toString() + " = " + System.getenv(object.toString())); } windows = System.getProperty("os.name").toLowerCase().startsWith("windows"); linux = System.getProperty("os.name").toLowerCase().startsWith("linux"); sunos = System.getProperty("os.name").toLowerCase().startsWith("sun"); freebsd = System.getProperty("os.name").toLowerCase().startsWith("freebsd"); if (linux || sunos) { //USR2-Signal-Handel lookup internal Server STATUS for Linux or SunOS System.err.println("::: " + new Date() + "::: run unter Linux or SunOS :::"); addUnixSignalStatusHandle(); } else if (freebsd) { System.err.println("::: " + new Date() + "::: run unter FreeBSD :::"); } else if (windows) { //Gracefull Shutdown JFrame for Windows, because can not kill -15 <pid> on Window or in Eclipse Console System.err.println("::: " + new Date() + " ::: run unter windows :::"); addWindowsShutdownHandle(); } else { System.err.println("UNKNOWN OS:" + System.getProperty("os.name")); } status = STATUS_STARTING; Server server = new Server(); Thread serverThread = new Thread(server); serverThread.start(); //Thread can stop by Shutdown-Hook while (true) { try { Thread.sleep(10000); } catch (InterruptedException e) { e.printStackTrace(); break; } } }