Platform independence in software means that you can run the same code with little or no modification on multiple platforms.
The devil is in the details:
- It depends on what you define as "the platform". In some cases this may be a specific hardware / machine configuration. In other gases in may be a "generic PC". In other cases it may be a virtual machine and runtime environment (which is the case with Java).
- Nothing is "perfectly" platform independent - there are always a few corner cases that can catch you out. For example, if you hardcode file path separators rather than using the platform independent File.pathSeparator in Java then your code won't work on both Windows and Linux. As a programmer, you need to watch out for these things, always use the platform independent option where possible and test properly on different platforms if you care about portability.
- There are always some constraints on specific platforms that cannot be ignored. Examples are things like the maximum length of filenames, or the available RAM on a system. No matter how much you try to be platform independent, your code may fail if you try to run it on a platform that is too tightly constrained.
- It's important to note that some langauges are platform independent at the source code level (C/C++ is a good example) but lose platform independence once the code is compiled (since native code is platform specific). Java retains platform independence even after code is compiled because it compiles to platform independent bytecode (the actual conversion to native code is handled at a later time after the bytecode is loaded by the JVM).
- There are occasionally bugs in language implementations that only occur on certain platforms. So even if your code is theoretically 100% portable, you still need to test it on different platforms to make sure you aren't running into any unusual bugs!
In the specific case of Java:
Java code is platform independent in the sense that the same Java application or algorithms (typically compiled to Java bytecode and packaged in a .jar file) will run identically on Windows and Linux.
Java libraries (e.g. all the nice open source toolsets) are usually platform independent, as long as they are written in pure Java. Most libraries try to stick with pure Java in order to maintain platform independence, but there are some cases where this is not possible (e.g. if the library needs to interface directly with special hardware, or call a C/C++ library that uses native code).
The Java platform / runtime environment is platform independent in the sense that the same libraries (images, networking, File IO etc.) are available and work in the same way on all platforms. This is done deliberately in order to allow applications that use these libraries to be able to run on any platform. For example, the Java libraries that access the filesystem know the fact that Windows and Linux use different filename path separators, and take account of this for you. Of course, this means that under the hood the runtime environment does make use of platform-specific features, so you need a different JRE for each platform. You can see a list of some of the available platforms on the Java download site: http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u26-download-400750.html
The JVM itself (i.e. the Java Virtual Machine that is responsible for JIT compililng and running Java bytecode) is platform independent in the sense that it is available on many platforms (everything from mainframes to mobile phones). However specific versions of the JVM are needed for each underlying platform to take account of different native instruction codes and machine capabilities (so you can't run a Linux JVM on Windows and vice Versa). The JVM is packaged as part of the Java platform / runtime environment as above.
Overall, Java is probably about as close to true platform independence as you can get, but as you can see there is still quite a bit of platform-specific work done under the hood.
If you stick to 100% pure Java code and libraries, my experience is that you can count on Java as being "effectively" platform independent and it generally lives up to the Write Once Run Anywhere promise. But you should still test it!!