If you write a program in Java, you can make it able to be run on a desktop computer. On a desktop computer, a Java program can either run in a web browser or as a standalone program. This allows a wider range of users. In addition, Java programs can run unmodified on Mac, Windows, and Linux computers if the Java Virtual Machine is installed. By contrast, C and C++ programs generally must be recompiled for each type of computer before they can be run; moreover, C and C++ programs may require significant modification before they can run on one type of computer.
Java is also the primary programming language that is used to write programs that run on Android-based mobile devices, such as smartphones. When Java is used to create programs for Android devices, rather than use the Swing and AWT toolkits to create a program's graphical user interface, the Android libraries and application framework are used instead. There are many similarities between the Java Virtual Machine that is used on a desktop computer and the Virtual Machine that runs on Android (Dalvik).
In fact, there are enough similarities that one could write a program that runs on Java on a desktop computer and then then make a few modifications to its code so that it runs on Android devices. By this process, it would be possible to increase the number of potential users of your Java programs even further. Moreover, currently, a popular integrated development environment for writing Java programs for the desktop PC, Eclipse, is also currently the primary integrated development environment for writing Android programs in the Java language.