Java is designed to be portable, but there are some things that differ between platforms. Some of these are extreme differences that couldn't be made a generic part of the language.
Whenever converting Strings to bytes, the default Unicode codepage to use for the translation must be specified, otherwise the JVM will use the default codepage for the platform the software is running on.
Trap: As an example, you can't convert a String to bytes on an EBCDIC mainframe platform, send it via TCP/IP to a Windows PC, convert it back to a String at the destination on an ASCII platform and expect to get the same result.
Software should also query the File class for the appropriate path separator character to use when creating a file path String.
The common list of platform related problems are as follows:
Callouts to native code in shared objects or DLLs. These are generally not portable.
Converting between String types and byte streams (e.g. serialization).
The way file paths are represented. Some operating systems use forward slashes and others back slashes. Luckily you can use forward slashes on both Windows and Unix platforms (the former is assumed to be on the C drive).
Variation in special character sets that are allowed to be used in the source code. e.g. String specialCee = "Ć"; Best not to use them.
Java for embedded devices is different to mainstream Java – it has a smaller set of commands.