Passing environment variables to a JVM, in a platform-independent manner

后端 未结 3 971
离开以前
离开以前 2020-12-30 23:30

I\'m developing a J2EE application that runs in JBoss on a Windows Vista machine, but the application will end up on a Linux machine. Is there a way to pass in the value of

3条回答
  •  清酒与你
    2020-12-31 00:35

    Yes - getEnv() will just return the name of the environment variable, and you can set it in whatever way is appropriate to the platform you're running on (typically via a launch batch file on Win32). It's good practice to fall back on sensible defaults based on the platform (by inspecting System.getProperty("os.name")), if it's possible you want to avoid having your users bother with needing to mess with environmental variables to run your software.

提交回复
热议问题