The Java Virtual Machine (JVM) provides platform independence by abstracting differences between operating systems and CPU architectures. It allows Java code to run on any system that has a JVM installed. The JVM acts as an abstraction layer between Java applications and the underlying platform, interpreting Java bytecode instructions. This makes Java highly portable and allows programmers to "write once, run anywhere".