title: Why is Java platform independent in theory and platform dependent in practice?
body: <p>I know that one of the big things about Java is that it is platform independent in the sense that you can make a Java application and have it run in Windows, Linux, Mac, and so forth, as long as you don't use libraries specific to one OS, and as long as you have a JVM installed for the appropriate OS to interpret things correctly...</p>
  
  <p>However, why can't a normal computer Java program (as in a simple Hello World in Java, for Windows or Linux for example) run just the same in a mobile phone, when mobile phones also have their specific JVM installed to interpret things correctly?</p>
  
  <p>Why is it necessary to change the architecture of the program in some cases, such as Android development, or use Java ME to make applications specific for some general mobile phones?</p>
  
  <p>I know that there are some functions that are related to certain functionalities of the OS, that might not apply in the mobile platforms for example, such as some things related with console, input methods, and so forth, but is this really the only reason that makes things not compatible? If so, why won't a simple application that just declares and initializes an integer variable be able to run across all non-mobile and mobile platforms that have a JVM available?</p>
  
  <p>I am aware of other questions that have been posted before, such as <a href="https://stackoverflow.com/questions/3420779/is-java-completely-platform-independent">this</a>, but that do not focus the exact point I am aiming for here.</p>