Monday 29 April 2013

Compile Once - Run Anywhere

In the previous example, I compiled and ran prog11 on a Solaris machine. Java is designed to be platform independent or portable. To show that it could be run on a different platform, I copied the prog11.class file to a Windows 7 machine in binary mode. Then I ran it there as follows:
 
C:\Java>dir
Volume in drive C is System
Volume Serial Number is B068-444A
 
Directory of C:\Java
 
04/29/2013  05:37 PM    <DIR>          .
04/29/2013  05:37 PM    <DIR>          ..
04/29/2013  05:36 PM               717 prog11.class
               1 File(s)            717 bytes
               2 Dir(s)  204,152,512,512 bytes free
 
C:\Java>java prog11
a = 100
b = 100
 
C:\Java>

If you have a Java book on Amazon, which you would like to advertise here for free, please write to me at international_dba@yahoo.co.uk.