• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
abhay jain
Ranch Hand
Posts: 130
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
akhter wahab
Ranch Hand
Posts: 151
Java MyEclipse IDE Python
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 1
  • Mark post as helpful
  • send pies
  • 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:

 
Campbell Ritchie
Sheriff
Pie
Posts: 47232
52
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Maneesh Godbole
Saloon Keeper
Posts: 10971
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another on guaranteed to fail in non-windoze platforms
Runtime.getRuntime.exec("explorer...");
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic