Java Magazine, Mar/Apr 2018
ORACLE COM JAVAMAGAZINE MARCH APRIL 2018 100 fix this Javas write once run anywhere promise is an important feature of the languages popularity Java bytecode is a machine like language that is not specific to any particular CPU hardware but is easy and reasonably eficient to execute on any hardware By compiling the source language to bytecode instead of to native machine language the result can be executed on any computer equipped with a JVM In addition to the design and availability of the JVM the Java system as a whole includes extensive libraries and these have been carefully designed to allow for equivalent behavior on different operating systems However its possible for the programmer to request some actions that will not work properly across all operating systems and all hardware environments For example while the method java nio file Paths get allows you to access files and directories regardless of the format of the paths notably their separators on differing hosts its also possible to try to access files in a way that would work on one operating system but fail on another On the topic of paths and the differences in file system behavior among operating systems its possible to get into trouble because Java is almost entirely case sensitive so class A and class a would properly be two distinct classes and they could coexist in the same package However in an operating system that does not distinguish case in its file system this would fail More platform variations that can cause trouble if approached clumsily relate to the screen Different systems will have different screen resolutions and creating windows of fixed sized could make a program unusable on a small screen Similarly diferent hosts have diferent fonts available with diferent geometries and these issues too can cause trouble if the programmer fails to follow some established guidelines The classic but tempting error is to position graphical items in a window using absolute coordinates rather than using one of Javas layout managers By doing this critical elements can become obscured and inaccessible on some hosts The meaning of names and the this and super keywords appearing in a lambda body along with the accessibility of referenced declarations are the same as in the surrounding context except that lambda parameters introduce new names
You must have JavaScript enabled to view digital editions.