• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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.
 
Do the next thing next. That’s a pretty good rule. Read the tiny ad, that’s a pretty good rule, too.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic