• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

portability

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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....
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Willie Smits increased rainfall 25% in three years by planting trees. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic