What Issues prevent Java applications from working on multiple platforms?

后端 未结 8 2123
南笙
南笙 2020-12-14 08:59

Java is supposed to be \"write once, run anywhere\" and it really can be, but in some cases it turns into \"write once, debug everywhere\".

What are the most common

相关标签:
8条回答
  • 2020-12-14 09:27
    • Don't make assumptions about the case (in)sensitivity of the file system
    • Don't make assumptions about the path or directory separator
    • Don't make assumptions about the line terminator
    • Don't use the default platform encoding unless you're really, really sure you mean to
    • Don't start "cmd.exe" etc (I know, it sounds obvious - but I've seen it cause problems)
    0 讨论(0)
  • 2020-12-14 09:31

    Off the top of my head...some of these actually happened at work

    • JNI

    • Development tool introduced characters into formatted string literals that worked under Windows but didn't work under Linux (this actually happened)

    • File system inconsistencies (tightly coupling an application to one environment)

    • Underlying hardware such as available memory or cores could result in a change of behavior

    0 讨论(0)
  • 2020-12-14 09:33

    Using JNI is something that should be looked into. Providing the native library for every target platform can reduce this problem.

    0 讨论(0)
  • 2020-12-14 09:39

    I can only speak from personal experience. These are things I've seen:

    1. Threading is abstracted differently on some architectures, so there are slight differences in delays and possibly ordering. (Which could lead to some race conditions)
    2. Controlling the keyboard's statuses (caps lock, num lock, etc) doesn't always work as expected (Linux didn't allow me to change the caps lock to disabled v1.5 at the time)
    0 讨论(0)
  • 2020-12-14 09:39

    Assuming you can write to the directory that contains your applications.

    0 讨论(0)
  • 2020-12-14 09:40

    There are many different JVMs, so depending on which one the client has installed on their box, they may get slightly different results.

    0 讨论(0)
提交回复
热议问题