Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
I'm pretty sure swing apps looking different is a feature. Way back when, people complained about java apps not looking "native" enough. – Karl Bielefeldt Mar 6 '12 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. – alain.janinm Mar 6 '12 at 20:56
Ive heard of an increase in memory footprint (exe & Usage), anyone care to confirm/deny ? – NWS Mar 6 '12 at 22:14
up vote 8 down vote accepted

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".

share|improve this answer
Thanks for the precision about Swing and GUI. Love the "write once, test everywhere" ;) – alain.janinm Mar 6 '12 at 16:09
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 – alain.janinm Mar 6 '12 at 16:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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