2010/06/27

Eclipse Helios Release Has Arrived




The Helios release is the largest release train produced by the Eclipse community, including 39 different project teams, over 33 million lines of code are released and the work of 490 committers. The release train makes it easier for users and adopters of Eclipse technology to adopt new versions of the different Eclipse projects. The Eclipse community also makes available 12 different Eclipse packages that target different types of developer usage, including Java EE developers, PHP developers, C/C++ developers and many more.
"The Helios release is another fantastic effort by the Eclipse committer community", explains Mike Milinkovich, Executive Director of the Eclipse Foundation. "Besides the feat of coordinating such a large development effort, Helios introduces important innovations in areas such as Git support, Linux development and JavaScript support. Congratulations to everyone for another great release"
The Helios release including many new features and projects updates. Some of the highlights include:
  • A new Linux IDE package makes it easier for Linux developers to use an integrated tool chain for building C/C++ applications for the Linux operating system. This package includes the new Linux Tools project which includes Eclipse integrations of popular Linux utilities such as GNU Autotools, Valgrind, OProfile, RPM, SystemTap, GCov, GProf, and LTTng. A recent Eclipse Community Survey has shown increased use of Linux by developers. It is expected this package will help further accelerate Eclipse adoption in the Linux community.
  • Eclipse Marketplace Client provides developers an 'app-store' experience to easily discover and install new Eclipse plug-ins. Eclipse Marketplace is a catalog of Eclipse based solutions. Over 100 of these will be available from the new Marketplace Client, making it significantly easier to find and install Eclipse solutions.
  • Support for Git, a popular distributed version control (DVCS), is provided by the new Eclipse EGit and JGit projects. The new EGit 0.8 release includes a new Git repositories view and support for fast forward merging and tagging. JGit 0.8 - which EGit uses under the covers to talk to Git repositories - benefited from performance enhancements of up to 50% when working with large repositories.
  • The Web Tools Platform project has introduced support for creating, running, and debugging applications written for the latest Java EE Specifications (Java EE 6) including, Servlet 3.0, JPA 2.0, JSF 2.0, and EJB 3.1.
  • Improved support in the JavaScript Development Tools project (JSDT) for JavaScript developers, including a JavaScript debug framework that allows for integration of JavaScript debuggers, such as Rhino and Firebug. A new JavaScript IDE package has also been created to make it easier for JavaScript developers to find, install and use an Eclipse-based IDE.
  • Eclipse Xtext 1.0, a popular framework for creating domain specific languages (DSL), introduces 80 new features, including improved performance and scalability by up to 30 times previous versions. A new in-memory indexing feature makes it possible to develop more sophisticated DSL's in Xtext.
  • A new release of Acceleo 3.0 implements the OMG Model-to-text (MTL) specification and provides the features required for a code generator IDE. This release also provides unique tools around example-base design of code generators.
More information about the Helios release can be found at www.eclipse.org/helios. The Helios packages can be downloaded now at www.eclipse.org/downloads.

Source : eclipse.org

2010/06/24

Read Contacts using JSR75

This MIDlet reads the contact names and numbers from the Phonebook using JSR 75
 
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
 
public class   PIMMidelt extends MIDlet 
{
 ReadPIM readPim;
 Display display;
 
 public void startApp()
 {
  display = Display.getDisplay(this);
  readPim  = new ReadPIM(this);
  display.setCurrent(readPim);
 }
 public void pauseApp()
 {
 }
 public void destroyApp(boolean uc)
 {
 }
}
 
 
import javax.microedition.lcdui.*;
import javax.microedition.pim.*;
import java.util.*;
import java.io.*;
public class ReadPIM extends Form  implements Runnable,CommandListener
{
 PIM pim;
 PIMList pimlist;
 Contact contact=null;
 Enumeration enumeration;
 PIMMidelt midlet;
 
 String contactName="";
 String contactNo="";
 
 
 StringItem name;
 StringItem telno;
 Thread thread=null;
 Command exitCmd = new Command("Exit",Command.EXIT,1);
 
 public ReadPIM(PIMMidelt midlet)
 {
  super("Reading contacts");
  this.midlet = midlet;
 
  pim = PIM.getInstance();
 
  thread = new  Thread(this);
  thread.start();
  addCommand(exitCmd);
  setCommandListener(this);
 
 }
 
 public void run()
 {
  readContacts();
 }
 
 public void readContacts()
 {
  String[] lists = pim.listPIMLists(pim.CONTACT_LIST);
  for (int i = 0; i < lists.length; i++)
  {
  try{
  pimlist = pim.openPIMList(pim.CONTACT_LIST,pim.READ_WRITE);
  }catch(Exception e){}
 
 
  try{
  enumeration = pimlist.items();
  }catch(Exception e){}
 
  while (enumeration.hasMoreElements())
  {
   contact = (Contact)enumeration.nextElement();
 
   try{
   if(pimlist.isSupportedField(Contact.FORMATTED_NAME)&& 
                               (contact.countValues(Contact.FORMATTED_NAME) >0))
    {
     contactName += contact.getString(Contact.FORMATTED_NAME,0) 
                                                                   +"\r\n";;
     System.out.println("COntact name:"+contactName);
    }
  }catch( Exception e){}
 
  int phoneNos = contact.countValues(Contact.TEL);
  try{
   if(pimlist.isSupportedField(Contact.TEL) && 
                                           (contact.countValues(Contact.TEL) >0))
   contactNo += contact.getString(contact.TEL,0) +"\r\n";
    System.out.println("contact No  :"+contactNo);
   }catch( Exception e){}
 
  }
 
  name = new StringItem("Name",contactName);
  telno = new StringItem("No",contactNo);
  append(name);
  append(telno);
 
  }
 }
 
 public void commandAction(Command c , Displayable d)
 {
  if(c == exitCmd)
  {
   midlet.destroyApp(true);
   midlet.notifyDestroyed();
 
  }
 
 }
}

2010/06/16

NetBeans 6.9 final release




NetBeans IDE 6.9 introduces the JavaFX Composer, a visual layout tool for visually building JavaFX GUI applications, similar to the Swing GUI builder for Java SE applications. Additional highlights include OSGi interoperability for NetBeans Platform applications and support for developing OSGi bundles with Maven; support for JavaFX SDK 1.3, PHP Zend framework, and Ruby on Rails 3.0; as well as improvements to the Java Editor, Java Debugger, issue tracking, and more.

2010/06/14

How to get Phone IMEI number with J2ME


International Mobile Equipment Identity (IMEI) is used to identify valid devices connected to GSM and UMTS network. This number can be accessed from a mobile phone by dialing *#06# on the keypad. IMEI is commonly use by software developers as part of software protection scheme to prevent it from being pirated.
JavaME developers however suffers from a drawback because MIDP/CLDC specification does not include an API to obtain IMEI from mobile devices. However there are few phone manufacturers included this functionality through System.getPropery() calls.
Here's how to get IMEI number from mobile devices of different manufacturers

Nokia
JAVA:
  1. System.getProperty("phone.imei");
  2. System.getProperty("com.nokia.IMEI");
Note ; Requires signed midlet. S60 3rd edition device does not requires signing for this to work.
Sony-Ericsson
JAVA:
  1. System.getProperty("com.sonyericsson.imei");
Note ; might not work on all model, YMMV
Motorola
JAVA:
  1. System.getProperty("IMEI");
  2. System.getProperty("com.motorola.IMEI");

Samsung
JAVA:
  1. System.getProperty("com.samsung.imei");
Siemens
JAVA:
  1. System.getProperty("com.siemens.imei");
Hopefully this information can aid you in your J2ME programming projects.
Quick Tip :
It's quite hard to determine the phone model/manufacturer well ahead beforehand. For a more robust solution, I suggest that you combine the above call with System.getProperty("microedition.platform").

2010/06/12

Java ME

Overview

Java Platform Micro Edition or Java ME (formerly J2ME) refers to a a collection of technologies and specifications to develop applications and games for (usually) mobile devices using Java Technology. Most of these technologies have been specified in open manner in Java Community Process by Nokia, Sun Microsystems, Motorola, Ericsson, Siemens, and others. There are many implementations available in different platforms. Nokia has internally developed Java ME implementations for both Series 40 and S60 platforms. These implementations are continually being refined with new APIs and other functionality.
Nokia phones have an extensive Java ME API set. For reference documentation, tutorials, and examples, see Nokia Java ME Developer's Library.


Architecture
 
The architecture includes:
See also the J2ME Mindmap.
MIDP 2.0 with CLDC is the common architecture found in the mass market. CDC with Personal Profile has more to offer to developers, but there aren't many devices yet with this configuration.
If you are using MIDP, you are developing MIDlets.


Java ME configurations
Connected Limited Device Configuration 
The CLDC covers devices below 512k size of memory for the JVM environment and removes JNI, user-defined class loaders, some class verification items of the class verification process (the reason why we MIDlet Preverify MIDlets compiled to be deployed on CLDC devices) and reflection to fit into this small footprint. The JVM on CLDC devices is called KVM (K-VirtualMachine), nicknamed K-VirtualMachine for kilobyte. The application lifecycle concepts from javaTV and the installation concepts of javaPhone found their way into this Connected Limited Device Configuration.
Connected Device Configuration 
The CDC covers devices above the 512k size of memory for the JVM environment. The garbage collector is a separate pluggable item into the CVM deployed on CDC devices. The threads are implemented not as OS specific but as fully implemented threads within the CVM and are known as Green Threads. Threads can also be implemented as OS native threads. Class file verification takes place in the CVM on the device just as in Java SE java platform on desktop systems. The JVM on CDC devices is known as a CVM or the C-VirtualMachine.


Java ME profiles

Profiles provide APIs that focus on a specific group of devices. These devices typically have the same or similar user intefaces (screen and inputs), how the device connects to the network, how the device stores data, and etc. Currently, the Profile Name indicates the Family name of this group of devices or a common functionality with this group of devcies. For example, the MIDP (MID Profile) is for the group of Mobile Information Devices. Java ME profiles are:
Mobile Information Device Profile 
The Mobile Information Device Profile (MIDP) extends and enhances the CLDC to provide a Java environment to develop applications on Mobile information appliances and voice communication devices. The versions of MIDP are:
Foundation Profile 
The Foundation Profile is what can be called a vertical specification profile. A vertical specification profile specifies the targeted family of devices by memory size and the optional profiles that may plugin more functionality in addition to this profile. The GUI APIs are often Profiles plugged in on top of this Profile. Typical rich network devices include set top boxes(iTV), auto-computing(telematics), and etc.
Personal Profile 
This Personal Profile provides high web fidelity to device with a rich network connection and can use the heavy weight applet classes that were part of the PersonalJava spec. While Personal Profile, JSR62, supports PersonalJava1.1.x and PersonalJava1.2.x of the PersonalJava Application Environment; Personal Profile 1.1 supports the adoption of the subset of J2SE1.4 APIs as Personal Profile 1.0 was based on the subset of J2SE1.3 APIs.
Personal Basis Profile 
This Personal Basis Profile provides a basic graphical user interface, ie the AWT lighweight APIs, on top of the CDC and Foundation Profile and is considered as a subset to the Personal Profiles. This profile also provides the xlet classes required for JavaTV.
Information Module Profile 
This Information Module Profile supports embedded network connected devices without a graphical user interface. This profile is a subset of the MIDP1.0 profile without the LCDUI classes of MIDP1.0. The typical devices target are modems, household devices, and industrial metering devices. While IMP is a subset of MIDP1.0, IMP-NG is a subset of MIDP2.0.
Digital Set Top Box Profile 
This Digital Set Top Box Profile is a subset of JavaTV and is targeted for the smaller set top boxes that deploy OCAP. Thus, this profile differs from the javaTV(CDC, PP PBP) setup in that its on top of CLDC not CDC to support a smaller device memory foot print. However, several concepts are borrowed from the JavaTV items in Personal Basis Profile such as the xlet lifecycle.


How to start

Java ME APIs in Nokia devices

See Additional APIs available for Java ME and Mobile Service Architecture for more information on APIs.
  • FileConnection API (JSR-75 Optional package)

    • javax.microedition.io.file
  • PIM API (JSR-75 Optional package)

    • javax.microedition.pim
  • Bluetooth API (JSR-82)

    • javax.bluetooth
    • javax.obex
  • MIDP 2.0 (JSR-118)

    • java.lang
    • java.util
    • javax.microedition.io
    • javax.microedition.lcdui
    • javax.microedition.lcdui.game
    • javax.microedition.media
    • javax.microedition.media.control
    • javax.microedition.midlet
    • javax.microedition.pki
    • javax.microedition.rms
  • MMAPI (JSR-135)

    • javax.microedition.media
    • javax.microedition.media.control
    • javax.microedition.media.protocol
  • CLDC 1.1 (JSR-139)

    • java.io
    • java.lang
    • java.lang.ref
    • java.util
    • javax.microedition.io
  • WSA (RPC Package) (JSR-172)

    • java.rmi
    • javax.microedition.xml.rpc
    • javax.xml.namespace
    • javax.xml.rpc
  • WSA (Parser Package) (JSR-172)

    • javax.xml.parsers
    • org.xml.sax
    • org.xml.sax.helpers
  • SATSA API (JSR-177)

    • java.lang
    • java.rmi
    • java.security
    • java.security.spec
    • javacard.framework
    • javacard.framework.service
    • javacard.security
    • javax.crypto
    • javax.crypto.spec
    • javax.microedition.apdu
    • javax.microedition.io
    • javax.microedition.jcrmi
    • javax.microedition.pki
    • javax.microedition.securityservice
  • Location API (JSR-179)

    • javax.microedition.location
  • SIP API (JSR-180)

    • javax.microedition.sip
  • M3G API (JSR-184)

    • javax.microedition.m3g
  • WMAPI (JSR-205)

    • javax.wireless.messaging
  • M2G API (JSR-226)

    • javax.microedition.m2g
    • org.w3c.dom
    • org.w3c.dom.events
    • org.w3c.dom.svg
  • AMMS API (JSR-234)

2010/06/03

NetBeans 6.9 RC2 Available



NetBeans IDE 6.9 introduces the JavaFX Composer, a visual layout tool for visually building JavaFX GUI applications, similar to the Swing GUI builder for Java SE applications. Additional highlights include OSGi interoperability for NetBeans Platform applications and support for developing OSGi bundles with Maven; support for JavaFX SDK 1.3, PHP Zend framework, and Ruby on Rails 3.0; as well as improvements to the Java Editor, Java Debugger, issue tracking, and more.
 

Accessing a .NET Web Service


From Forum Nokia Wiki


For this example, we're going to access this .NET web service:
http://www.webservicex.net/stockquote.asmx
If you navigate there, you'll see a description of the service, and it's one method: GetQuote(String symbol). We're going to invoke that method remotely from a Java ME MIDlet.

Generating the Stub Class

We need the Web Service Description Language (WSDL) description for the service. Luckily, .NET services supply this for you is you append "?WSDL" to the URL.
The Java ME SDK contains a tool called "wscompile", that reads the WSDL data and generates a "stub" Java class. This class acts as a local proxy for the remote service. You call a method in the stub class, and it calls the remote method for you.
To generate the stub class, we need a config.xml file.
 version="1.0"?>

 xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/config">

  location="http://www.webservicex.net/stockquote.asmx?WSDL" packageName="rpcdemo" />

The wsdl location must match the URL for the service (with "?WSDL" tacked on the end). The packageName is the package for the generated files.
\Java_ME_platform_SDK_3.0\bin\wscompile.exe -gen -cldc1.1 config.xml
You should specify -cldc1.1 if the web service might use floats or doubles as arguments or return value.
After executing this, you should have a file (amongst others) for the class: rpcdemo.StockQuoteSoap_Stub
Add the generated classes to your project in your IDE.

Using the Stub Class

Here's a MIDlet that will invoke the GetQuote method (which wscompile has renamed getQuote(), to match the Java convention).
Since the method is remote, invoking it might be time consuming, so it needs to be done in a separate thread. Therefore, the interesting part of the following code is the run() method.
package rpcdemo;

 

import javax.microedition.midlet.MIDlet;

import javax.microedition.lcdui.Command;

import javax.microedition.lcdui.CommandListener;

import javax.microedition.lcdui.Display;

import javax.microedition.lcdui.Displayable;

import javax.microedition.lcdui.Form;

 

public class RpcDemo extends MIDlet implements CommandListener, Runnable {

 

    private Form form;

 

    public void startApp() {

        if (form == null) {

            form = new Form("RpcDemo");

            form.addCommand(new Command("Exit", Command.EXIT, 0));

            form.setCommandListener(this);

 

            // get the data

            (new Thread(this)).start();

        }

        Display.getDisplay(this).setCurrent(form);

    }

 

    public void pauseApp() {

        // empty

    }

 

    public void destroyApp(boolean must) {

        // empty

    }

 

    public void commandAction(Command c, Displayable d) {

        if (c.getCommandType() == Command.EXIT) {

            notifyDestroyed();

        }

    }

 

    public void run() {

        try {

            // create the stub

            StockQuoteSoap_Stub service = new StockQuoteSoap_Stub();

            // set the URL for the service

            service._setProperty(javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY, "http://www.webservicex.net/stockquote.asmx");

 

            println("Connecting...");

            // invoke the remote method

            String xmlResponse = service.getQuote("NOK");

            println(xmlResponse);

 

            println("Done.");

        } catch (Exception e) {

            println(e.toString());

        }

    }

 

    private void println(String s) {

        form.append(s + "\n");

    }

}

Processing the Response

The response comes back as a String, which should look something like:


 

  NOK

  12.76

  4/23/2010

  4:00pm

  -0.23

  12.70

  12.76

  12.57

  50259424

  47.317B

  12.99

  -1.77%

  12.10 - 16.58

  0.00

  N/A

  Nokia Corporation

 

Since this is XML, you can process it using the XML parsing features of JSR 172. For more information about that, see JSR 172: XML Parsing Example.