Sun's motto, or core value proposition, for Java is "Write once, run anywhere." Java makes it easy to write portable programs, but Java programs do not automatically run successfully on any Java platform. The following tips help to avoid portability problems. Portability rules like those listed here were the focus of Sun's now-defunct "100% Pure Java" certification program and branding campaign.
Portable Java code can use any methods in
the core Java APIs, including methods implemented as
native methods. However, portable code must not
define its own native methods. By their very nature, native methods
must be ported to each new platform, so they directly subvert the
"Write once, run anywhere" promise
Runtime.exec( ) method to spawn a process and
execute an external command on the native system is rarely allowed in
portable code. This is because the native OS command to be executed
is never guaranteed to exist or behave the same way on all platforms.
The only time it is legal to use
is when the user is allowed to specify the command to run, either by
typing the command at runtime or by specifying the command in a
configuration file or preferences dialog box.
System.getenv() is nonportable. The method was
deprecated but has been reintroduced in Java
Portable Java code must use only classes and interfaces ...