Apr 25, 2015

Java: The once and future king of Internet programming

Built for embedded computing and streamlined for real-time, here's why Java is the language of IoT

What is Java to you? A programming language you learned in college? The lingua franca of corporate IT? Would you believe that Java is poised to dominate the next explosion of the Internet? Built for embedded computing and streamlined for real-time applications, here's why Java is the language for IoT.
The years from 1969 to present saw networked devices balloon from four university computers connected via the ARPANET to about two billion humans frequently accessing the Internet today. In the near future that number will exponentially multiply again, from a couple billion networked devices to tens of billions of embedded processors. Every aspect of our lives will be connected by networked devices: homes, workplaces, vehicles, appliances, tools, toys --you name it.
While chatter about the Internet of Things (IoT) includes a component of fashionable hype, the underlying reality is that imminent changes in Internet growth will make previous generations of computing look trivial by comparison. IoT is not only here to stay; it's here to change everything. Consider the following timeline, which shows previous tipping points for the Internet as we have known it:
Complementary technologies that enable IoT are coming online now. HTTP/2 is a crucial networking protocol that has been updated, in part, to accommodate machine-to-machine communications. Thingsee is an example of a developer kit for the kind of hardware that IoT will demand.
Silicon Valley sage Tim O'Reilly has emphasized that the result will not be just the usual caricature of pointless connections from coffee machines or refrigerators to the 'Net at large. With enough sensors and automation, IoT is really about human augmentation. Java will be a workhorse in that coming disruption.

How IoT works

In September 2014, Andrew C. Oliver wrote that at an implementation level IoT is about teamwork. In this case, the teamwork involves both humans and computers.
As devices communicate not just with human consumers, but with other devices, fundamentally new capabilities emerge. It's not only that your refrigerator will know you have run out of tomatoes, but that it can place an order for more on your behalf. The success of pervasive computing will be that it recedes into the background, working out facts and events and remedies with other connected devices. Only executive-level results will be communicated to human consumers. The triumph of IoT will be in all the things that we no longer have to think about, even as they are seamlessly done for us.
The most mundane examples are the most telling. Leave aside just-in-time agricultural pest treatmentsminiaturized bomb-sniffersimproved medical diagnostic technology, or similarly impressive applications of IoT in recent news. Think instead of the humble vending machine -- one that's properly stocked, well maintained, and always silently awaiting your command.

When you place your bills in a vending machine and push buttons to indicate your purchase, several mechanisms interact to ensure the satisfaction of your hunger. You don't have to understand or agree with all the details of implementation; your stomach is just happy with the results. Now, we have IoT-enabled vending machines. When you make a purchase from an IoT-enabled vending machine, your purchase triggers actions spanning the globe to keep inventory in balance and parts well-maintained, at a total cost 30 percent lower than the pre-IoT model.

Java for embedded computing

Few people today realize that Java began as a language for embedded computing. Its earliest versions specifically targeted home appliances such as television set-top interfaces. Communication between devices was central to James Gosling's original vision for Java, and he envisioned it being used for not only device-to-consumer but device-to-device communication. Twenty years later, those original design strengths are ready to support the Internet of Things.
Java's ubiquity also makes it a good fit for IoT. Massive resources worldwide are invested in transmitting Java to a new generation of programmers and ensuring that it is maintained to support all the production systems that rely on it. Hundreds of thousands of successful applications and systems already attest to Java's capabilities.
For developers exploring embedded programming it is important to distinguish the parts of the Java platform. Nothing about how you code or read programs needs to change for embedded programming: good Java programmers can read embedded source code just as easily as they do the source for typical desktop enterprise applications. The libraries, and especially the development (and testing) environments, are specialized for embedded Java programming, however. Just be sure that you have the right toolchain for the embedded environment you target.

Java embedded programming in 2015

Java already had the right stuff to make embedded programming possible in 1996, but it lacked momentum. Today that momentum is gathering fast, and an ecosystem of Java standards and tools for embedded programming is ready to leverage it.
Between 2000 and 2010, it was generally true that Java-based embedded or "micro" computing centered on J2ME(Jave 2 Platform, Micro Edition). Now, Java Platform, Micro Edition, or Java ME, is the standard runtime environment for embedded applications. While Java ME and its concepts --especially profiles andconfigurations --remain crucial, mobile Java developers tend to focus more on Android, and HTML5 for user interfaces. Cellular telephone handsets are the most visible embedded computers, and roughly four out of five mobiles sold now are based on Android. (Although Android supports Java ME, the two have different product lifecycles, and it's not entirely clear who will decide what the next generation of application environments for practical embedded devices will be.)
Profiles and configurations are crucial concepts in embedded programming. Anembedded profile such as MIDP is a collection of APIs supported on devices of interest. A configuration is a framework specification. While not strictly true it can be useful to think of profiles as belonging to configurations, including most prominently the CLDC or Connected Limited Device Configuration. (Also see "Jim Connors' Weblog" to learn more about profiles and configurations applicable to IoT.)
In addition to Java ME's profiles and configurations, a handful of enterprise Java technologies hold potential for embedded development. Java Management Extensions (JMX) is used for distributed resource management and monitoring and could one day complement embedded definitions neatly. Real-time Java also holds an important place in embedded programming for IoT.

Java's real-time model and tools

Embedded applications connected to sensors and effectors in medical, transportation, manufacturing, and other domains often have important real-time requirements. Predictable, correct results from heart pacemakers, engine controllers, pipeline valves, and so on are matters of life and death, not just annoying stack tracebacks.
While James Gosling intended Java to fulfill common real-time requirements, real-time computations weren't a strength of Java in its early years. In particular, many Java runtimes had a reputation for unreliability, or at least inconsistency in how they handled garbage collectionReal-Time Specification for Java (RTSJ) and related standards addressed temporal indeterminacy with support for periodic and sporadic task scheduling, task deadlines and CPU time budgets, garbage-collecting threads, and allowances that enable certain tasks to avoid garbage collection delays. RTSJ was approved in 2002 and has been implemented for a number of Java VMs.
Although RTSJ was officially listed as dormant in the Java Community Process until February 2015, specification experts have been actively at work refining and updating it throughout the last decade. As an example, JamaicaVM is an RTSJ implementation supported by aicas GmbH, available at no charge for educational and other non-commercial use.

More recently, Oracle has promoted Java SE for real-time systems, suggesting that Java SE has been enhanced sufficiently to meet soft real-time requirements. Soft here has at least two distinct related meanings. One is that requirements have to do with average behavior; for instance, it's good enough that an average bank transaction will post within 300 milliseconds. This is in contrast to hard real-time requirements, such as the requirement that a particular locomotive-switching solenoid close at worst within one-and-a-quarter seconds of the application receiving a specific alarm. The most important requirement for hard real-time systems, in this sense, is that the worst case must be predictable.
Soft real-time is good enough for many embedded and IoT applications. For applications that require hard real-time support, Java developers largely turn to JSR-302: Safety Critical Java Technology. This spec is a subset of the Real-Time Specification for Java, and parts of it depend on the CLDC. Among other features, Safety-Critical Java defines its own concurrency model and real-time threadsThe Open Group industry consortium originally began work on Safety-Critical Java in 2003. Asked about the spec's status, JSR-302 specification lead Doug Locke estimated that its long gestation will lead to an approved specification this spring, with a reference implementation possible by early May 2015.

Next up in Java embedded

Java holds much promise for embedded programming, and there is work to be done in order to enable it to meet the coming explosion of demand and possibility in IoT.Tens of billions of Java-capable devices will go into use as part of the IoT network over the next few years. My next article on this topic will feature specific examples of programming for embedded Java environments in both hobbyist and commercial contexts, along with a deeper explanation of why RTSJ 2.0 will impact Java far beyond traditional domains for real-time programming.

Apr 24, 2015

Java ME 8 and the Internet of Things

Because recently I started to work with Java mostly, I have read a lot of Java Documentation and a lot of news regarding Java. Following these I just found out that the Twitter uses Java and no Ruby anymore.

Last year I've worked a bit with Java ME. And I just read this: Internet of Thinks.

An overview and resource guide for developers new to embedded Java and IoT

Embedded systems are computer systems embedded into complete devices, whose dedicated functions reside within a larger mechanical or electrical system. Typically used in both industrial and consumer applications, embedded systems are entering the limelight with the Internet of Things (IoT). For developers just getting started with IoT, this article is a guide for learning more about the technologies that comprise Oracle's IoT platform: Java ME 8, Java ME Embedded, Java SE Embedded, and Java Embedded Suite.

In 1991, Mark Weiser, then head of Xerox's Palo Alto Research Center (PARC), attempted to capture the coming age of ubiquitous computing. Noting that "[t]he most profound technologies are those that disappear," Weiser described the various thought and technical experiments conducted by his colleagues at PARC, as they sought a new way of thinking about computers as embedded systems. Their vision, which might have seemed as fantastic as a hovercraft in 1991, is quickly becoming more commonplace today:
Sal awakens: she smells coffee. A few minutes ago her alarm clock, alerted by her restless rolling before waking, had quietly asked, "Coffee?," and she had mumbled, "Yes." "Yes" and "no" are the only words it knows [...]
At breakfast Sal reads the news. She still prefers the paper form, as do most people. She spots an interesting quote from a columnist in the business section. She wipes her pen over the newspaper's name, date, section, and page number and then circles the quote. The pen sends a message to the paper, which transmits the quote to her office [...]
Once Sal arrives at work, the foreview (in her car) helps her to quickly find a parking spot. As she walks into the building the machines in her office prepare to log her in ...

The embedded devices in Weiser's workday morning scenario use sensors to track a human user's interactions, and wireless connectivity to orchestrate a response: Sal's bed, alarm clock, and coffee maker are all connected to ensure that her first cup of coffee is underway before she rolls out of bed. For Weiser and his colleagues, this was calm computing; today we might call it the Internet of Things (IoT).

IoT overview

If there is one defining characteristic of IoT, it is interoperability, or the coordination of multiple devices. As observed in the above scenario, IoT uses sensors to collect data (in that case about Sal's interactions in her environment) and wireless connectivity to orchestrate a response. IoT is built on a confluence of technologies, including new and old hardware platforms, big data, cloud computing, and machine-to-machine (M2M) computing. APIs are the necessary glue, bringing all of these moving parts together.

Most importantly for Java developers, Java is key to many of the emerging IoT technologies already, and Oracle has committed to making Java a leading platform (if not the platform) for IoT. Java ME 8 breathes new life into Java's small device technology, extending it with a differentiated line of embedded Java platforms.
The next sections will introduce the technologies that comprise Oracle's IoT platform; follow the links to learn more about Java ME, Java ME 8, and the three embedded frameworks: Java ME Embedded, Java SE Embedded, and Java Embedded Suite.


Java ME

Java Micro Edition was originally intended to address the constraints associated with building applications for small devices. Based on Java SE, Java ME (or J2ME, as we knew it in 1999) was the platform for Java applications running on small devices with limited memory, display, and power capacity. Today it is used to develop embedded systems, ranging from industrial controls to mobile phones (especially feature phones), to set-top boxes and Blu-ray players.
Developers working in Java ME can choose from multiple configurations, profiles, and optional packages:
  • A configuration provides the most basic set of libraries and virtual machine capabilities for a broad range of devices.
  • A profile is a set of APIs that support a narrower range of devices.
  • An optional package is a set of technology-specific APIs. The Wireless Messaging API is one example. Check out Oracle's optional package primer to learn more about optional packages.

Configurations and profiles

In time two configurations have emerged: Connected Limited Device Configuration (CLDC) is the configuration for small devices, and Connected Device Configuration (CDC) is the configuration for more capable mobile devices such as smartphones and set-top boxes.
Java ME profiles sit on top of configurations, defining higher-level APIs of use to particular applications. Mobile Information Device Profile (MIDP), for instance, sits on top of CLDC and provides user interface, networking, and persistent storage APIs. Applications that run in a CLDC/MIDP environment (such as games) are known as MIDlets.

Java ME 8

In late 2012, Oracle embarked on an ambitious project to deliver a major update of the Java ME platform standard. Two Java Specification Requests (JSRs) were designed to meet current market requirements for embedded devices and prepare Java ME for future Java platform specifications: JSR 360 (CLDC 8), an evolutionary update to CLDC 1.1.1, would bring the virtual machine, Java language, and libraries up to date with Java SE 8. JSR 361 (Java ME Embedded Profile/MEEP 8) would update Information Module Profile - Next Generation (IMP-NG).

CLDC 8 and MEEP 8

CLDC 8 is based on JSR 139 (CLDC 1.1) and aligns the core Java ME virtual machine, language support, libraries, and other features with Java SE 8:
  • The virtual machine has been updated to comply with version 2 of the JVM specification.
  • Newer Java SE language features such as generics, assertions, annotations, and try-with-resources are now supported.
  • New libraries such as Collections, NIO subset, and Logging API subset are now supported.
  • A consolidated and enhanced Generic Connection Framework for multi-protocol I/O is supported.
MEEP 8 updates the original IMP-NG specification to provide a powerful and flexible application environment for small embedded Java platforms. The specification builds on CLDC 8 with the following features:
  • A new, lightweight component and services model
  • Shared libraries
  • Multi-application concurrency, inter-application communication, and event system
  • Application management
  • API optionality to address low-footprint use cases

The long, strange life, death, and rebirth of Java

Java at 20: Where do we go from here?


 May 23, 1995 saw the fruits of a four-year project at Sun Microsystems called Java. The new language with a C-like syntax promised the ability to write once and run anywhere through the use of virtual machines that compiled the code on the native platform at runtime.

The project began in 1991 when a small group of Sun engineers called the "Green Team," led by James Gosling, began working on a language and networking system for the next generation of digital consumer devices and computers.

In the 20 years since its launch, Java has exploded in use, been the subject of lengthy litigation with Microsoft, grew and died on the desktop, moved to the server, then jumped to feature phones, only to have its lunch eaten by smartphones, fallen into such disarray that the Department of Homeland Security said not to use it, and is now enjoying a renaissance under the stewardship of Oracle.
What other programming language can claim such drama?

When the project began, Sun saw a collision of the computer industry and non-computer industry technologies like cell phones to stereo systems to railroads to whatever. Sun noticed that they were all, in some form or another, reinventing computer science.

"The unifying theme was networking," said Gosling, now chief software architect for Liquid Robotics. "When we looked at these companies, they were designing their own networking and doing a really bad job of it. A lot of it was predictable. They were repeating a number of experiments we'd had in computer science 30 years ago."

The problem was the consumer electronics people didn't take networking into account, like common APIs across multiple platforms, or code reuse. "There was essentially no software reuse. Everybody was reinventing everything over and over again. We were trying to get to a place where we had models to help them get out of that," said Gosling.

"I really think Java's future is in IoT. I'd like to see Oracle and partners focused on a complete end-to-end storage solution for Java, from devices through gateways to enterprise back-ends. Building that story and making a success of it will help cement the next 20 years for Java. Not only is that a massive opportunity for the industry, but also one I think Java can do quite well." - Mike Milinkovich, executive director of the Eclipse Foundation

Read more here: http://www.javaworld.com/article/2912380/java-platform/the-long-strange-life-death-and-rebirth-of-java.html

No more Security fixes for Java 7

Oracle to end publicly available security fixes for Java 7 this month

Users are advised to migrate to Java 8

Public updates for Java 7 -- including bug and security fixes -- will end this month, a situation that one security advocate says could impact millions of applications.

"As outlined in the Oracle JDK [Java Development Kit] Support Roadmap, after April 2015, Oracle will not post further updates of Java SE [Standard Edition] 7 to its public download sites," Oracle's Java SE Support Roadmapstates. "Customers who need continued access to critical bug fixes and security fixes as well as general maintenance for Java SE 7 or older versions can get long-term support through Oracle Java SE Support. The process of migrating users from Java 7 to Java 8 through the auto update feature is expected to take place after the January 2015 CPU release."

Oracle released Java SE 7 in July 2011; Java SE 8 was released in March 2014. Java, particularly on the client side, has been beset by security issues in recent years. But Oracle has taken many steps to address the issues and stressed that most of the problems dated back several years, before Oracle took over Java from Sun in 2010.

Still, the impact of Oracle's cessation of public updates could be severe, an official at security firm Waratek, believes. Oracle's "rapid" end-of-life schedule for Java versions is great for innovation and language evolution, Waratek CTO John Matthew Holt said in an emailed statement. "However, there is a dangerous tradeoff; now millions of Java 7 applications will have to defend themselves against code-level vulnerabilities without the benefit of future fixes." Holt advocates either upgrades to Java 8 or use of Java Run-time Application Self Protection (RASP) technologies (Waratek is a RASP vendor).

This week's security update from Oracle, meanwhile, marks the "proverbial 'end of the road' for Java 7 application security, Holt said. "After today, the only version of the Java Platform which will receive public security updates is Java 8.  This is huge news, and it is going to cause enormous headache and disruption to millions of application owners around the world."
Contacted Tuesday afternoon for a comment on the end of public updates for Java SE 7, by late evening Oracle had not yet responded.

The April 2015 Critical Patch Update released Tuesday by Oracle provides 98 new fixes for security issues across a wide range of product families, said Eric Maurice in an Oracle blog post. These range from Oracle Database to Oracle Fusion Middleware, Java SE, and MySQL. Fourteen of the security fixes are for Java SE.

This story, "Oracle to end publicly available security fixes for Java 7 this month" was originally published by InfoWorld.



Apr 21, 2015

Java - check if file exists

When you try to see if a file exists then you can use
File.exists()
as here:

  public int existsFile(){
            /**
             *  @author     Me
             *  @descr      This function check if the file exists
             */
            
            int x = 0;      //      0 - file doesn't exist
                            //      1 - file do exists 
            String name_path_file = "C:/temp/myFile.tmp";
            File fisier = new File(name_path_file);
            if(fisier.exists()){
                x = 1;
            }            
            return x;   

        }