Java is known to be portable; "compile once, run anywhere". I know this is often true because I have many times deployed jar or war without any cross-platform troubles. Still, I am left wondering if this is always true.

For example, Swing applications look different between different OS platforms. Also, JDK-1.7 is still a preview release for Mac OS X.

So, what are the common problems that prove that Java applications are not entirely cross platform?

  • I'm pretty sure swing apps looking different is a feature. Way back when, people complained about java apps not looking "native" enough. Mar 6, 2012 at 20:46
  • Yes, you're right, when I say "look different" I mean in the bad way. For example I made vertical panes, it work on Linux and Windows but on Mac, labels inside don't appear. Mar 6, 2012 at 20:56
  • Ive heard of an increase in memory footprint (exe & Usage), anyone care to confirm/deny ?
    – NWS
    Mar 6, 2012 at 22:14

1 Answer 1


Swing is platform-dependent to a certain extent. In addition to the widget themes being different, as you noted, we've had Swing-based applications where the layout is different from platform to platform. There was also another group I worked in that had some widgets not even show up on certain platforms.

I'm not sure how big a problem this is though, because I'm not sure how much Swing is used anymore. Eclipse's SWT seems to be a lot more platform-independent, so it seems that Java + GUI doesn't necessarily imply non-portability.

Also, any Java code that uses the operating system or makes assumptions about the underlying platform will naturally be less portable, for reasons including (but not limited to):

  • case (in)sensitivity of the filesystem
  • newline characters
  • threads/processes

(Many of these can be easily handled by Java APIs -- System.getProperty("line.separator");).

As a counterpart to the saying you mentioned, some of the more experienced programmers in my group say that Java is "write once, test everywhere".

  • Thanks for the precision about Swing and GUI. Love the "write once, test everywhere" ;) Mar 6, 2012 at 16:09
  • 1
    I'm reading that SWT is based on AWT heavyweight component and AWT is why Swing suffer of platform dependancy no? "James Gosling, the creator of the Java language, has argued that SWT is too simple, and that SWT is a difficult toolkit to port to new platforms for the same reason that AWT used to have porting problems" (from en.wikipedia.org/wiki/Standard_Widget_Toolkit) Mar 6, 2012 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.