Java is a cross-platform, language meaning it can be able to run in any computer platform. Java can run directly on any platform without manual intervention because it is written in pre-compiled portable byte code whereby interpreters or runtime packages are standard elements of all computer platforms. As far as java is concerned it is just the software environment where it runs and java platform has two components: the Java Virtual Machine and the Application Programming Interface.
JVM refers to an abstract machine whereby the java precompiled programs are executed. The same was designed to be simple as well as being small so as to be able to be installed in various places possible and this made java possible to run across all platforms. This forms a common software layer for all and in heterogeneous network environment thus eliminating portability limitations. API refers to a collection of software elements that offer a good number of utilities for example the GUI.
Java classes have same format, therefore, code compilation can be done in the same manner in all platforms. However, JVM will require that it be written for specific platform since this is that part that modifies java byte code to native byte code. This is the reason why Java Runtime Environment for precise platform has to be installed since it has the JVM.
An advantage of java being platform-independent is its ability to be move from one computer platform to another without any problem, that is, it is portable.
A major disadvantage for java being platform-independent is that java platform is slow compared with native code.
Whelan, P. F., & Molloy, D. (2001). Machine vision algorithms in Java: techniques and implementation. New York: Springer.