aspose file tools*
The moose likes Beginning Java and the fly likes write once run any where or and compiled once run any where Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "write once run any where or and compiled once run any where " Watch "write once run any where or and compiled once run any where " New topic
Author

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

abhay jain
Ranch Hand

Joined: Jun 03, 2011
Posts: 130
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

Joined: Mar 02, 2009
Posts: 151

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


Start Earning Online||Start Earning Using Java
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14345
    
  22

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:


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39828
    
  28
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

Joined: Jul 26, 2007
Posts: 10523
    
    9

Another on guaranteed to fail in non-windoze platforms
Runtime.getRuntime.exec("explorer...");


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
 
wood burning stoves
 
subject: write once run any where or and compiled once run any where