Nov 9, 2015

HTML5 mobile app

I tried to develop an mobile app using HTML5 on Intel SDK. The app is quite ok on my old mobile phone a Samsung 6 years old. But on my actual phone which is an Nexus 5 the app has the font too small and the images are too small, as  well. So, I started to a lot of documentation on internet and I had to accumulate a lot of frustration with it. Nothing to help me, indeed. A lot of solutions consisting in modifying css to build 2 or 3 files for css just to increase the font when you have high density of pixels as for Retina display.
But, some of the solutions were with  viewport solution. But most of them haven't work for me.
And, after 3 day research I found something that helped me.

This page helped me: http://ariya.ofilabs.com/2011/08/mobile-web-logical-pixel-vs-physical-pixel.html
But they have something wrong in their code. So, I had to modify this to work well for me.

For Android, we apply the density DPI approach and now it becomes:
Here I had to modify like this:

2 maximum-scale=2 user-scalable=no”> 
And, also, I had to use this javascript function at onLoad body:
function schimbaPixelii(){
    var el, width, height;
    if (window.devicePixelRatio === 1) {
    if (window.innerWidth === 2 * screen.width ||
        window.innerWidth === 2 * screen.height) {
        el = document.getElementById('viewport');
        el.setAttribute('content', 'width=device-width, target-densityDpi=device-dpi ' +
            'initial-scale=1, maximum-scale=1, user-scalable=no');
        document.head.appendChild(el);
        width = window.innerWidth;
        height = window.innerHeight;
        if (width === 2 * screen.width) {
            width /= 2;
            height /= 2;
        }
    }
}
}

Oct 3, 2015

cURL

Not Curl.

cURL is a way you can hit a URL from your code to get a html response from it. its use for command line cURL from the php language.
php
//step1
$cSession = curl_init(); 
//step2
curl_setopt($cSession,CURLOPT_URL,"http://www.google.com/search?q=curl");
curl_setopt($cSession,CURLOPT_RETURNTRANSFER,true);
curl_setopt($cSession,CURLOPT_HEADER, false); 
//step3
$result=curl_exec($cSession);
//step4
curl_close($cSession);
//step5
echo $result;
?> 
step1: Initialize a curl session use curl_init().
step2: Set option for CURLOPT_URL. This value is the URL which we are sending the request to. Append a search term "curl" using parameter "q=". Set option for CURLOPT_RETURNTRANSFER, true will tell curl to return the string instead of print it out. Set option for CURLOPT_HEADER, false will tell curl to ignore the header in the return value.
step3: Execute the curl session using curl_exec().
step4: Close the curl session we have created.
step5: Output the return string.
public function curlCall($apiurl, $auth, $rflag)
{
    $ch = curl_init($apiurl);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    if($auth == 'auth') { 
        curl_setopt($ch, CURLOPT_USERPWD, "passw:passw");
    } else {
        curl_setopt($ch, CURLOPT_USERPWD, "ss:ss1");
    }
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $dt = curl_exec($ch);        
    curl_close($ch);
    if($rflag != 1) {
        $dt = json_decode($dt,true);        
    }
    return $dt;
}
this is also use for authentication.and we can also set the user name password for authentication for function user you can see the
http://php.net/manual/en/ref.curl.php
http://www.startutorial.com/articles/view/php-curl

Sep 23, 2015

Generate random string with PHP

If you want to generate random code with PHP you can use this function:

<?php
public function genRandmStr($lgt = 8){
       
        $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_@#!';
        $charactersLength = strlen($characters);
        $randomString = '';
        for ($i = 0; $i < $lgt; $i++) {
            $randomString .= $characters[rand(0, $charactersLength - 1)];
        }
        return $randomString;
    }
}

// you can see the result here
echo genRandmStr();
?>

Sep 18, 2015

CakePHP how to retrieve POST and GET vars

When you are working with CakePHP framework and you try to retrieve the variables which have been sent through GET or POST.

For POST variables you have

For $_POST['key']  we have
$this->request->data('key');


For GET variables you have

For $_GET['kpa']  we have
$this->request->query('kpa');


Sep 8, 2015

HTML5 vs HTML

There is some differences between HTML and HTML5. So though, we have:

HTML5 was designed to replace both HTML 4, XHTML, and the HTML DOM Level 2.
And XHTML is HTML + XML. For a better syntax and for a better administration they had to force HTML to be proper: for instance, if you open this tag <p> you have to close the tag with </p>.

The main goals of HTML5 are:
- Deliver rich content as graphics or movies without the need of additional plugins as Flash, for instance;
- Provide better semantic support for web page structure. For this, HTML5 introduces new structural element tags;
- Provide better cross-platform support (for PC browser, tablet or smartphone);
- Provide a stricter parsing standard to simplify error handling, ensure more consistent cross-browser behavior.

HTML5 has improved the support for embedding graphics, video and audio. For that HTML5 has some new tags: <canvas>, <audio>, <video>

HTML5 has introduced web workers. A web worker is a script that runs in the background, in another thread, without the page has to wait for it to complete. The visitor can continue to interact with the page while the web worker runs in the background.


HTML5 has new semantic tags to complement the structural logic of modern web applications. Here we have:
<main>
<nav>
<article>
<section>
<header>
<footer>
<aside>

HTML5 has new controls like
<calendar>
<date>
<time>
<email>
<url>
<search>



HTML5 has new extensions to the Javascript API as geolocation, drag-and-drop, storage and caching.

Aug 28, 2015

CakePHP and PHP version

I was trying to code at my project. It was OK on my localhost webserver. But... when I moved the files on the real webserver I had a problem.
I didn't know what could that be. I got errors just on some pages. Not at all pages of my website.
Then, I realized that, perhaps, my version of PHP could be too old. Actually, not my version but real webserver version.

Indeed, the problem it was with PHP version which is 5.3 and this version doesn't know about the arrays declared like this:

$ar = ['key1' => 'value1', 'key2' => 'value2'];

It knows only like this:

$ar = array('key1' => 'value1', 'key2' => 'value2');

I got this issue when I tried to make a Form and I finished to have this PHP code

echo $this->Form->input('name', [
                'label'=>[
                    'class' =>  'ContactInput',
                    'text'  =>  'Name:' . $messgError['name']
                ]

            ]);



Aug 26, 2015

CakePHP 2 - Forms

When you try to create a new form in CakePHP framework using FormHelper, you may have this error:

Missing Database  Table
And if you read very carefully  the Book of CakePHP will see something like that:

You can also pass false for $model. This will place your form data into the array: $this->request->data (instead of in the sub-array: $this->request->data['Model']). This can be handy for short forms that may not represent anything in your database.
So, in your view file like APP/View/Contact/index.ctp, you have  to start with this line:

echo $this->Form->create(false, array('url' => '/contact'));

Good luck!

Aug 19, 2015

CakePHP 2.* how to use custom complex sql Query with model

Let's suppose that we have MySQL database with table categories:

CREATE TABLE `categories` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `category` varchar(64) DEFAULT NULL,
  `description` varchar(64) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB;


Then, in CakePHP framework, you want to call a simple query as you did it with mysql_query in PHP with no framework.

For that you have the class Model::query()

First, you build the model. You don't want to use predefined Models for a table (like the model Categories for DB table Categories). Because you want to use perhaps this query for extracting data from two tables which are related.

So,  first you have to create the model. For this you have to create the file APP/Model/Categs.php



class Categ extends AppModel {

    public $useTable = false; // it is mandatory to have this line. Whithout this line, 
                              //                                    the Controller will search for table Categ; it doesn't matter that you have a sql query  

    public function getDataFromMyTable(){
        $d = $this->query("SELECT * FROM  categories");
        return $d;
    }

}


Second, you have to create the Controller. The file will be: APP/Controller/CategsController.php


class CostsController extends AppController {
    
    
    public function index(){
        $this->loadModel('Categ');
    
        $rezQuery = $this->Categ->getDataFromMyTable();
        $this->set('cs', $rezQuery);
    }
}
?>


And now we have to create the view. We create folder APP/View/Categs (if this folder doesn't exists). And then we create the file index.ctp into this folder. The name of the ctp file should be the  same as name of the function from Controller. In index.ctp we write:


Aug 14, 2015

CakePHP and .ctp files

If you use CakePHP as PHP framework then you'll see some different types of files: CTP. And you'll need to see them as a php file in your PHP editor, Eclipse. For this you'll do this:

Preference>General>Content Types>Php then add *.ctp

And then you need to restart Eclipse IDE for have an effect.



CakePHP

Last 2 weeks I tried to put ZF2 to my project www.mateonline.net. It was endless pain to configure Zend Framework 2 for me as a beginner with this. ZF2 as syntax is very nice. But something got wrong with server configuration.
So, then I said I will try Symfony 2. But, I quit immediately. I though it will be easier, but it is no so nice as ZF2.
And, then I pass to CakePHP. Which I like. Except the fact that it has no PDO. I don't like  how is linked to MySQL DB but I can use to it.

Aug 3, 2015

PHP namespace

When you use namespace on PHP scripts you have to use require(), require_once(), include() or include_once() . It doesn't work without one of these like you can see on this example:

php namespaces are case-insensitive:

file1.php:
namespace foo;

function 
bar()
{
    echo 
'from bar';
}
?>
file2.php:


fOo
\bar() // output: from bar
?>
This example is here:
http://php.net/manual/en/language.namespaces.rationale.php

A better example is here:
http://www.sitepoint.com/php-53-namespaces-basics/

Jul 23, 2015

Javascript redirect for mobile devices

The best method to redirect for mobile that I found is following:


<script type="text/javascript">
if (screen.width < 1081) {
 var ref = document.referrer;
 var urls = new Array("http://www.mymainsite.com","http://m.mymobilesite.com");
 var n = ref.match(urls[0]);
 var m = ref.match(urls[1]);
 if ((m!==null) || (n!==null)) {
 stop;
 }
 else if (ref=='') {
 var r = confirm("Small Display is Detected.\nClick \"OK\" for MOBILE SITE.");
 if (r==true) {
  window.location = "http://m.mymobilesite.com";
  }
  else {
  stop ;
 }
 }
 else
 {
 window.location = "http://m.mymobilesite.com";
 } 
}
</script>

Angular JS

Last days I was struggling with implementation of Angular JS on one  my websites: www.pensiunealajura.ro/mobil/

The big issue with this was to list HTML code without listing HTML tags like < or >. For instance, I wanted to have

    This is a bold text.

not

  This is a <b>bold text</b>.

So, I tried to have this with the module ngSanitize and $sanitize and $sce with  $sce.trustAsHtml.

But all of these were not good. And i dug more. And I found out that the best way to write formatted HTML code into a web page using Angular JS  is using directive ngBindHtml as is explained here: 
https://docs.angularjs.org/api/ng/directive/ngBindHtml

Now, everything is ok with my page.
:)

May 30, 2015

News about Java

A new article about Java 20 years:

Java's 20 Years Of Innovation

The importance of a given programming language—especially one as pervasive as Java—in changing how people use technology is difficult to underestimate. The big data revolution, for example, is primarily a Java phenomenon. 
[...]
Fatigue with C
However, a fatigue with C was definitely emerging. The language had two major handicaps in those days: First, it was too low level—that is, it required too many instructions to perform even simple tasks. Second, it wasn’t portable, meaning that code written in C for the PC could not easily be made to run on minicomputers and mainframes.

The low-level aspects, which still are apparent today, led developers to feel that writing applications in C was akin to mowing the lawn with a pair of scissors. As a result, large software projects were tedious and truly grueling.
The portability of C was also a major problem. Although by 1995, many vendors had adopted the 1989 ISO standard, they all added unique extensions that made porting code to a new platform almost impossible.
It’s no coincidence, then, that this era saw the emergence of a new generation of languages. In 1995 alone, there appeared Ruby, PHP, Java, and JavaScript.
Java almost immediately became popular for mainstream programming due to its portability and large set of built-in libraries. The then-mantra for Java was “write once, run anywhere.” While not strictly true initially, it quickly became so, making Java a good choice for business applications that needed to run on several platforms.

http://www.forbes.com/sites/oracle/2015/05/20/javas-20-years-of-innovation/

 


May 22, 2015

Java at 20

Remembering what the programming world was like in 1995 is no easy task. Object-oriented programming, for one, was an accepted but seldom practiced paradigm, with much of what passed as so-called object-oriented programs being little more than rebranded C code that used >> instead of printf and class instead of struct. The programs we wrote those days routinely dumped core due to pointer arithmetic errors or ran out of memory due to leaks. Source code could barely be ported between different versions of Unix. Running the same binary on different processors and operating systems was crazy talk.

Java changed all that. While platform-dependent, manually allocated, procedural C code will continue to be with us for the next 20 years at least, Java proved this was a choice, not a requirement. For the first time, we began writing real production code in a cross-platform, garbage-collected, object-oriented language; and we liked it ... millions of us. Languages that have come after Java, most notably C#, have had to clear the new higher bar for developer productivity that Java established.


James Gosling, Mike Sheridan, Patrick Naughton, and the other programmers on Sun’s Green Project did not invent most of the important technologies that Java brought into widespread use. Most of the key features they included in what was then known as Oak found its origins elsewhere:
  • A base Object class from which all classes descend? Smalltalk.
  • Strong static type-checking at compile time? Ada.
  • Multiple interface, single implementation inheritance? Objective-C.
  • Inline documentation? CWeb.
  • Cross-platform virtual machine and byte code with just-in-time compilation? Smalltalk again, especially Sun’s Self dialect.
  • Garbage collection? Lisp.
  • Primitive types and control structures? C.
  • Dual type system with non-object primitive types for performance? C++.


May 18, 2015

MIPS

First of all, this morning I found out that exist two different MIPS in this world.

First MIPS is a reduced instruction set computer (RISC) instruction set architecture (ISA) developed by MIPS Technologies (formerly MIPS Computer Systems, Inc.).

The other MIPS is a software product. I wanted to talk about this one because I had to face it at my workplace. This MIPS is from Management & Information Processing Services. They said that this software is made to help you in your Management activities.

From my experience at my workplace this software help you to annoying you. It is ugly and difficult to use. It is not oriented to user. It is made to build another ugly thinks. MIPS solutions doesn't help you, MIPS generates a lot of new problems. Here we have built something very nice with webserver and external database using AJAX, jQuery for front-end for a wonderful experience for the final users. But, MIPS team came with something ugly and nonsense solution. They have been chosen because they are MIPS even their solution is a big problem for users teams. Because the IT management is old and they don't understand that we are in XXI century.

And how can you have trust in this kind of software when they have a website like this? http://www.mipssoftware.com/
* built like has been made in 1992.
* ugly and non-friendly structure
* unfinished texts
* Underconstruction ???? Since 2011.

STS

I've tried to make a Spring Java project. I tried and tried last week, but today I've discovered this: STS. Which is an Eclipse extension easy to build Spring Projects.

May 5, 2015

HTTP/2: A jump-start for Java developers

HTTP/2 was approved in February 2015 as the successor to the original web communication protocol. While it is in the last stages of finalization, the standard has already been implemented by early adopters such as Jetty and Netty, and will be incorporated into Servlet 4.0. Find out how HTTP/2 renovates HTTP's text-based protocol for better latency, then see techniques like server push, streaming, multiplexing, and header compression implemented in a client-server example using Jetty.


High-speed browser networking


In the early days of the World Wide Web, Internet connection bandwidth was the most important limiting factor for a faster browsing experience. That has changed in the years since, and these days many consumers use broadband technologies for Internet access. As of 2014, Akamai's State of the Internet report showed that the average connection speed for customers in the United States exceeded 11 Mbit/s.
As Internet connection speeds have increased, the importance of latency to web application performance has become more apparent. When the web was new, the delay in sending a request and waiting for a response was much less than the total time to download all of the response data, but today that is no longer the case. "High bandwidth equals high speed" is no longer a valid maxim, but that doesn't mean we can ignore the importance of bandwidth. For use cases that require bulk data transfer such as video streaming or large downloads, bandwidth is still a roadblock. In contrast to web pages, these types of content use long-running connections, which stream a constant flow of data. Such use cases are bandwidth bound in general.

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