Java is a programming language as well as a platform of its own. Isn’t it nice to know this, that we have a language that is platform independent? I never believed this till I saw how Java is platform independent.I wrote a code in Windows, compiled it in Windows and wanted to test it in Linux or UNIX machine. I managed to get a UNIX machine and installed Java and JRE on that machine. Yes I had to set up the class-path in it. Once I did that, I copied the java classes that I had compiled in Windows and put that in to UNIX machine. I though it will surely ask for some change in the code, and will throw some unexpected, run-time exception. But anyways I had no choice of compiling it and therefore i just simply ran it. I ran it and yes I saw that it ran perfectly fine without any error. Without even changing one word in the Java file I could run that in UNIX machine. The only thing failed was the path of the file that I had given in one of the java code. For e.g.: “C :\\\” . This caused problems while running in UNIX, as it could not find the directory. This was supposed to be changed to the UNIX directory and with double slashes.But yes there is a roundabout for this too. The file path can be put in a key-value pair and then the key is to be called in the program. This way, the only thing that should be changed is the value, and the key will remain the same. This key –Value pair can be put in some properties file that can be referred in to the java code.
so therefore Windows or UNIX
You just can exchange,
Your Java code will run
Without any change.
Kind of late to the party, don't you think?
ReplyDelete