You Are Here:

Community: Wiki

This page was last modified on 5 June 2009, at 12:26.

How to retrieve version number of Java Runtime for S60

From Forum Nokia Wiki

Contents

Overview

Nokia S60 devices come equipped with an implementation of Java Platform Micro Edition (ME), hereby called Java Runtime x.y for S60, or shortly JRT x.y. Starting from S60 3rd Edition FP2 Java implementations are versioned separately from underlying S60 Platform. For example, Java Runtime 1.3 for S60 (JRT 1.3) is the current version shipping with Nokia 5800 XpressMusic (sw 20.0.012 and onwards). The exact version returned by Java environment is 1.3.4. There will be release note documents available on Forum Nokia wiki pages, which explain the version features in details. Please read the "See also" section below for more information.

Currently the version of JRT can be checked by using standard MIDP system property "microedition.platform". For example in S60 5th Edition device Nokia 5800 XpressMusic this system property returns:

NokiaN5800d-1/20.0.012/sw_platform=S60;sw_platform_version=5.0;java_build_version=1.3.4

Here is a full working sample MIDlet code below. The VersionMIDlet reads the system property and parses the details (device, its software version, platform and its version and JRT version) and prints them on the screen.

Source code: VersionMIDlet.java

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.midlet.MIDlet;
 
/**
* <p>Title: VersionMIDlet</p>
* <p>Description: This MIDlet shows the value of the "microedition.platform"
* system property and also the parsed values of the details in it. It uses
* the methods in the PlatformDetails class for the parsing.</p>
*/

 
public class VersionMIDlet extends MIDlet implements CommandListener {
private Form form;
private Command exitCommand;
private PlatformDetails details;
private String device = "";
private String sw = "";
private String platform = "";
private String platform_version = "";
private String java_version = "";
 
public void startApp() {
form = new Form("VersionMIDlet");
exitCommand = new Command("Exit", Command.EXIT, 1);
form.addCommand(exitCommand);
form.setCommandListener(this);
details = new PlatformDetails();
device = details.getDeviceName();
sw = details.getSwVersion();
platform = details.getPlatform();
platform_version = details.getPlatformVersion();
java_version = details.getJavaVersion();
form.append("microedition.platform = " + details.platformString + "\n\n");
form.append("Device: " + device + "\n");
form.append("Software version: " + sw + "\n");
form.append("Platform: " + platform + "\n");
form.append("Platform version: " + platform_version + "\n");
form.append("Java Runtime for S60: " + java_version + "\n");
Display.getDisplay(this).setCurrent(form);
}
 
public void pauseApp() {
}
 
public void destroyApp(boolean unconditional) {
}
 
public void commandAction(Command c, Displayable d) {
if (c == exitCommand) this.notifyDestroyed();
}
}


Source code: PlatformDetails.java

/**
* <p>Title: PlatformDetails</p>
* <p>Description: This class contains methods for parsing the details out of
* the system property value "microedition.platform". In S60 3rd Ed. FP2 (and newer)
* there are information about device name, software version, software platform and its
* version and Java version.</p>
* <p> For example in S60 3.2 device N85 this and request system property could return:
* NokiaN5800d-1/20.0.012/sw_platform=S60;sw_platform_version=5.0;java_build_version=1.3.4</p>
* <p>In older S60 devices (and Series 40 phones too) the returned value is typically
* something like this (showing device model and the sw version):
* NokiaE71-1/0.07.76</p>
* <p>In this case the returned values for other details than device name and sw version
* are "N/A".</p>
*/

public class PlatformDetails {
protected String platformString = System.getProperty("microedition.platform");
private int length = platformString.length();
 
public String getDeviceName() {
String device = "";
String string = "";
int index = 0;
char c = 'a';
while (device.equals("")) {
c = platformString.charAt(index);
if (c != '/') {
string += c;
index++;
}
else device = string;
}
return device;
}
 
public String getSwVersion() {
String sw = "";
String string = "";
int index = 0;
char c = 'a';
while (true) {
c = platformString.charAt(index);
if (c != '/') index++;
else break;
}
index++;
c = 'a';
while (c != '/') {
c = platformString.charAt(index);
string += c;
if (index < length) index++;
if (index == length) {
sw = string;
break;
}
}
if (sw.equals("")) sw = string.substring(0, string.length()-1);
return sw;
}
 
public String getPlatform() {
String platform = "";
String sw_platform = "sw_platform";
String test = "";
String s60 = "";
int sw_length = sw_platform.length();
int index = 0;
while (platform.equals("")) {
test = platformString.substring(index, index + sw_length);
if(test.equalsIgnoreCase(sw_platform)) {
index = index + sw_length + 1;
s60 = platformString.substring(index, index + 3);
if (s60.equalsIgnoreCase("s60")) platform = s60;
else platform = "N/A";
}
if (index < (length-sw_length)) index++;
else platform = "N/A";
}
return platform;
}
 
public String getPlatformVersion() {
String platformVersion = "";
int index = platformString.length()-1;
char c = 'a';
char temp_c = 'a';
while (platformVersion.equals("")) {
c = platformString.charAt(index);
if (c == ';') {
String temp = "";
int temp_i = index-1;
while (temp.equals("")) {
temp_c = platformString.charAt(temp_i);
if (temp_c == '=') temp = platformString.substring(temp_i + 1, index);
if (temp_i > 0) temp_i--;
}
platformVersion = temp;
}
if (index > 0) index--;
else platformVersion = "N/A";
}
return platformVersion;
}
 
public String getJavaVersion() {
String version = "";
String java = "java";
String test = "";
int index = length;
while (version.equals("")) {
test = platformString.substring(index - 4, index);
if(test.equalsIgnoreCase(java)) {
int c_index = 0;
int temp = 0;
char c;
for (int i = 1; i<12; i++) { // the version format is xxx.y.zzzzz
temp = length - i;
c = platformString.charAt(temp);
if (c == '=') c_index = temp;
}
version = platformString.substring(c_index + 1);
}
if (index > 4) index--;
else version = "N/A";
}
return version;
}
}

There are also the VersionMIDlet.jad and VersionMIDlet.jar files available here.

Example application

See also

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fThemesE3aHomeE5fScreenX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ