The "smart-ass" answer is "Only if your software is running on Unix" As long as you don't mind losing portability and "pure Java", you can use the various forms of Runtime.exec() to run external software on the host machine. Note that many commands available at the Unix prompt are actually implemented diredctly by your shell, so you may need to run them using a shell rather than directly. Also note that Runtime.exec() captures the standard input and standard output streams of the executed process, so don't expect diagnostic output to appear on the Java console.
Ambrose, Don't do it! You defeat the purpose of using JAVA (platform independent). What happens if you move your code to Windows? BOOM! You might as well use C/C++. If you can tell us the reason why you need to do it, we might suggest other work around that is JAVA compliant. -Peter
I'm stuck in a similar position to Ambrose. It is fairly critical that a program be aware of where it is running at, and that is one of the first reasons I would want to query environment variables. Knowing if your in test, or in production is critical.
Originally posted by Nate Mattson: ....and that is one of the first reasons I would want to query environment variables. Knowing if your in test, or in production is critical.
Setting system properties when starting a Java program from a command line is easy using the -D option; the program can query by property name: System.getProperty("thePropertyName"); Referencing the value of an environment variable from a command line (so you can pass it as system property) is possible in Unix and Windows, but the command line syntax varies. Unix: java -DthePropertyName=$theEnvVariableName Windows: java -DthePropertyName=%theEnvVariableName% Maybe this can help...
Power corrupts. Absolute power xxxxxxxxxxxxxxxx is kinda neat.
ScroogeXHTML - small and flexible RTF to HTML converter library