Platform independent in the case of
Java means that Java programs are completely independent of the operating system on which you run them. When you write a Java program, it can run on Windows, Linux, OS X or any other operating system without any changes or need to recompile the code (as long as there's a Java runtime environment available for the operating system).
Portable means that you can recompile the source code of a program to a platform-specific executable without changing the source code itself; you just need to compile it. The resulting executable will only work on the specific CPU type and operating system that you have compiled it for.
If you write a program in for example C++ and you use libraries and APIs that are for a specific operating system, then your program is not portable. You can't easily create a version of your program that would run on an Apple Mac, for example, because the Windows API that you used doesn't exist there.
Also in Java it's possible to write programs that are not platform independent. For example if you use paths in your code like "C:\Temp" etc. then it's not going to work on OS X or Linux, because path names look different on those operating systems.