Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What are some of the differences between developing

 
Jay Dilla
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in Windows and developing in Unix?
I've only developed in Windows environment, but I notice some jobs want people with Unix experience. Is there a big difference?
 
Felix Black
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
difference between windows and UNIX ?? .... yes ... they are totally different environments .... how that fact effects java programming i dont know.

Corect me on this, but java is totally portable due to its bytecode... so actually writing code on a UNIX, LINUX.. or any other platfomr shouldnt be that different.

Actualyl using the platform is another thing entirley ...
 
Campbell Ritchie
Sheriff
Pie
Posts: 49789
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java is not quite totally portable. There are difference between Java programming in Linux and Windows. I know about 4.
  • Different path separator, ; on DOS and Windows, : on Linux Unix and Mac.
  • Different line end, 0xd 0xa (\r\n) on DOS and Windows, 0xa (\n) on Linux, not sure on Mac.
  • Different file separator \ on DOS and Windows, / on Mac Unix and Linux
  • Different end-of-file, something with ctrl-Z on DOS and Windows, something with ctrl-D on Mac Unix and Linux.
  • There is a fuller list in some books [eg I think in: David Flanagan, Java in a Nutshell 5/e Sebastopol: O'Reilly (2005), maybe chapter 7]. You can get a list of different properties with a method called getProperties or similar in the System class.
     
    Sol Mayer-Orn
    Ranch Hand
    Posts: 311
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    1)
    Personally, i've had some rare cases when *threading* was a headache.
    There *are* well-known recommendations for correct, platform-independent threading programming in java (such as the famous "don't make too strong assumptions about Thread.setPriority").
    However, I was once involved in an application which used some 3rd partly library ("black box"), which worked on windows and crashed on Linux, opening way too many threads, which showed up as 'processes' , surprising Linux ignorats such as myself... calling over a Linux expert saved us some time, even for telling threads from processes and such like.

    2)
    Some employers may *also* want you to just be comfortable with the environment, regardless of java programming.

    E.g. suppose the application is finished, you just need to deply it to the target unix machine, executed, and possibly handle crashes and debugging.
    So you find yourself: writing some related shell scripts, defining some environment variables, zipping/unzipping resources, losing some files and having to use a 'find' command to look for them, needing to edit some configuration files using VI editor, then managing to freeze the entire application and having to kill the process... you get the idea.
     
    Jay Dilla
    Ranch Hand
    Posts: 201
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    thanks guys
     
    Jesper de Jong
    Java Cowboy
    Saloon Keeper
    Pie
    Posts: 15441
    41
    Android IntelliJ IDE Java Scala Spring
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by Campbell Ritchie:
    Java is not quite totally portable. There are difference between Java programming in Linux and Windows. I know about 4.
  • Different path separator, ; on DOS and Windows, : on Linux Unix and Mac.
  • Different line end, 0xd 0xa (\r\n) on DOS and Windows, 0xa (\n) on Linux, not sure on Mac.
  • Different file separator \ on DOS and Windows, / on Mac Unix and Linux
  • Different end-of-file, something with ctrl-Z on DOS and Windows, something with ctrl-D on Mac Unix and Linux.
  • There is a fuller list in some books [eg I think in: David Flanagan, Java in a Nutshell 5/e Sebastopol: O'Reilly (2005), maybe chapter 7]. You can get a list of different properties with a method called getProperties or similar in the System class.

    You should not hard-code path and file separators, end-of-line and end-of-file characters in your application, and you don't need to with Java.

  • Use java.io.File.pathSeparator instead of hard-coding ";" or ":" in paths.
  • Use java.io.File.separator instead of hard-coding "/" or "\" in file names.
  • Use System.getProperty("line.separator") to get the line separator of the OS your program is running on.


  • If you do that and watch out for other platform-specific things, your Java application will be fully "write once, run anywhere" - it will run on Windows as well as Unix without modification.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic