• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

portability

 
Padma Anand
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when I write a java program on win2k and compile it, will the compiled byte code run on any OS? or any necessary precautions need to be taken to make the code run on all the OSs. I was told by somebody that though java claims "write once and run everywhere" still some precautions have to be taken to run the code on different VMs. Can somebody let me know what precautions are necessary to make the code truly portable?
Thanks,
Padma.
 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Padma,
What you have heard is 100% correct. The Java programs run on top of the Virtual Mechine(VM). So you do not have to write different applications to different Operating Systems(O/S). So you can 'Write Once and Run Any Where'.But the precausions upto my knowledge are, things like the slashes which are used when specifying the path etc...
Hope you get some kind of an idea from this....
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ransika is quite correct. As long as you don't use any platform (operating system/hardware/etc.) code inside your Java classes they should work without change on any computer that has a JVM installed on it (if that JVM is of a version that supports code generated by your javac compiler of course, typically that means the same version or a newer one).
You can look up the documentation for java.lang.System which contains info on how to get the path separators etc. for the platform on which your application is running.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic