• 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

write once run any where or and compiled once run any where

 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
currently i have installed windows but if i installed Linux in my PC then in that case should i need to aware about coding style in any way ??


which one of the following can be proved wrong

a. write once run any where
b. compiled once run any where
 
Ranch Hand
Posts: 151
MyEclipse IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

abhay jain wrote: currently i have installed windows but if i installed Linux in my PC then in that case should i need to aware about coding style in any way ??


which one of the following better suits to java

a. write once run any where
b. compiled once run any where
c. both




both but it depends on your need if yo you don't need to change any thing you should use option b
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java bytecode is the same, no matter what operating system you run the program on, so normally you do not need to change anything in your source code, and you do also not need to recompile your source code to run on Linux instead of Windows.

Ofcourse it is possible to write programs that will only work on Windows. If you put absolute paths to files in your program that only exist on Windows, then on Linux it would not work:

 
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you use \\ to separate files, or ; tp separate paths, or \n as line terminators, or ctrl-D/ctrl-Z as end-of-transmission characters. All those things can tie you to a particular platform. I think there is a chapter in the O'Reilly book Java™ in a Nutshell which lists many more platform differences.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another on guaranteed to fail in non-windoze platforms
Runtime.getRuntime.exec("explorer...");
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic