×
Namespaces

Variants
Actions
(Difference between revisions)

Developing Nokia Asha apps on Linux

From Nokia Developer Wiki
Jump to: navigation, search
achipa (Talk | contribs)
m (Achipa -)
achipa (Talk | contribs)
m (Achipa -)
Line 1: Line 1:
 +
[[Category:Nokia Asha]][[Category:Linux]][[Category:Java ME]][[Category:Series 40]][[Category:IDE]][[Category:Tools for Java ME]]
 
{{Abstract|This article explains how to use the Nokia Asha SDK 1.0 under Linux with WINE.}}
 
{{Abstract|This article explains how to use the Nokia Asha SDK 1.0 under Linux with WINE.}}
 
{{ArticleMetaData <!-- v1.2 -->
 
{{ArticleMetaData <!-- v1.2 -->
Line 49: Line 50:
  
 
===Nokia Java SDKs===
 
===Nokia Java SDKs===
Now you can install the Nokia Java SDKs, available from [https://developer.nokia.com/Develop/asha/java/ here]. Always use the offline installers. Under Ubuntu, you can double-click the Nokia Asha SDK installer just as you did the JRE. [[image:Nokia Asha SDK install.png|thumb|Install Nokia Asha SDK 1.0 from Ubuntu]] On the final page, uncheck launch Nokia IDE for Java - at this stage it will not function. Depending on your Linux environment, you should have the emulator icons on your desktop.
+
Now you can install the Nokia Java SDKs, available from [https://developer.nokia.com/Develop/asha/java/ here]. Always use the offline installers. Under Ubuntu, you can double-click the Nokia Asha SDK installer just as you did the JRE. [[image:Nokia Asha SDK install.png|thumb|Install Nokia Asha SDK 1.0 from Ubuntu]] On the final page, uncheck launch Nokia IDE for Java - at this stage it will not function. Depending on your Linux environment, you should have the emulator icons set up on your desktop. Now you should be able to start the emulator as any other program.
 
+
[[image:Java emu desktop.png|SDK emulator shortcuts]]
+
 
+
Now you should be able to start the emulator as any other program.
+
  
 
[[image:Java emu running.png|thumb|Nokia Asha SDK 1.0 running under Wine]]
 
[[image:Java emu running.png|thumb|Nokia Asha SDK 1.0 running under Wine]]
Line 59: Line 56:
 
===Running Java ME apps in the emulator/SDK===
 
===Running Java ME apps in the emulator/SDK===
  
 
+
To run a .JAR of a Java ME application, you can either use the Open menu option (your native Linux filesystem is under the Z: drive), or simply drag-and-drop the jar file on the emulator
  
 
===Enabling the SDK for IDE usage===
 
===Enabling the SDK for IDE usage===
  
Java defines a way how SDKs and emulators are identified by SDKs. Unfortunately, even though the SDK's property file defines the correct executables, IDEs like netbeans look for hardcoded file names, and fails to find them. Thus, for the IDE to SDK link to work, we need to create symlinks in the SDK directory for the emulator and preverify executables.
+
Java defines a way how SDKs and emulators are identified by SDKs. In order for this to work with the Linux IDEs, these two files need to be added to the SDK install.
 +
 
 +
[[file:preverify|preverify]]
 +
[[file:emulator|emulator]]
  
 
[[image:SDK links.png|thumb|Creating the emulator and preverify softlinks]]
 
[[image:SDK links.png|thumb|Creating the emulator and preverify softlinks]]
Line 72: Line 72:
 
cp ~/Downloads/emulator
 
cp ~/Downloads/emulator
 
cp ~/Downloads/preverify
 
cp ~/Downloads/preverify
 +
 +
For the technically inclined, here is the explanation why this is required. Even though the SDK's property file defines the correct executables, IDEs like netbeans look for hardcoded file names, and fails to find them (the SDK directory has ''emulator.exe'' instead of ''emulator'', etc). The other problem is that of classpaths. The paths should be separated by a colon on Windows and a semicolon on Linux. The two scripts above thus provide the executables that can get called from the IDEs and do the string transformations so that each side (the native IDE and the SDK within wine) can exchange classpath definitions.
 +
  
 
===Netbeans===
 
===Netbeans===

Revision as of 20:34, 23 July 2013

This article explains how to use the Nokia Asha SDK 1.0 under Linux with WINE.

Article Metadata
Tested withCompatibilityArticle
Created: achipa (21 Jul 2013)
Last edited: achipa (23 Jul 2013)

Contents

Introduction

It is fully possible to develop Java ME and Nokia Asha Web Apps on Linux. The Web Apps development environment is available as a native applications for Linux (.deb package for Ubuntu/Debian) and does not require anything extra. Java ME apps can be developed in NetBeans or Eclipse and tested using the Oracle/Sun Java ME device emulators available in the Jave ME SDK. The emulator can also be integrated with your NetBeans or Eclipse installation.

While the Nokia Asha SDK is not available as native Linux applications, we can use the toolchain and emulator via Wine from IDEs like Netbeans or Eclipse running natively on Linux (thus there is no speed overhead in the IDE itself). This is only possible on 32-bit i386 Linux environments.

Installation

To start with you need to install a bit of software on your system first. Install, in order:

Wine

First you need to have Wine installed on your Linux system. How that is done depends on your distribution, under ubuntu you can do it via the Ubuntu software center.
Install Wine from the Ubuntu software center
If you prefer the console, on deb-based systems just enter from the command line:

sudo apt-get install wine

Check the Wine download page for instructions and packages for other distributions or newer version of Wine. The approach has been verified on Wine 1.4 and Wine 1.6

JRE

The new Asha SDK needs a JRE. Remember to install the (32bit) Windows version of the JRE from here. If you're running Ubuntu and have installed wine, just double-click the JRE exe file.
Install JRE from Ubuntu
The terminal equivalent is

wine /path/to/jre-7u25-windows-i586.exe

Nokia Java SDKs

Now you can install the Nokia Java SDKs, available from here. Always use the offline installers. Under Ubuntu, you can double-click the Nokia Asha SDK installer just as you did the JRE.
Install Nokia Asha SDK 1.0 from Ubuntu
On the final page, uncheck launch Nokia IDE for Java - at this stage it will not function. Depending on your Linux environment, you should have the emulator icons set up on your desktop. Now you should be able to start the emulator as any other program.
Nokia Asha SDK 1.0 running under Wine

Running Java ME apps in the emulator/SDK

To run a .JAR of a Java ME application, you can either use the Open menu option (your native Linux filesystem is under the Z: drive), or simply drag-and-drop the jar file on the emulator

Enabling the SDK for IDE usage

Java defines a way how SDKs and emulators are identified by SDKs. In order for this to work with the Linux IDEs, these two files need to be added to the SDK install.

preverify emulator

File:SDK links.png
Creating the emulator and preverify softlinks

Here's a plaintext version suitable for copy'n'paste

cd ~/.wine/drive_c/Nokia/Devices/Nokia_Asha_SDK_1_0/bin cp ~/Downloads/emulator cp ~/Downloads/preverify

For the technically inclined, here is the explanation why this is required. Even though the SDK's property file defines the correct executables, IDEs like netbeans look for hardcoded file names, and fails to find them (the SDK directory has emulator.exe instead of emulator, etc). The other problem is that of classpaths. The paths should be separated by a colon on Windows and a semicolon on Linux. The two scripts above thus provide the executables that can get called from the IDEs and do the string transformations so that each side (the native IDE and the SDK within wine) can exchange classpath definitions.


Netbeans

Install the latest netbeans (in case of Ubuntu, the recommendation is to download the Java SE version from the netbeans site as the Ubuntu packages are woefully out of date as per the time of writing of this article). Still, you can install netbeans 7.0.1 from the ubuntu software center

File:Netbeans install.png
Netbeans install from the Ubuntu Software Center

or from the command line

sudo apt-get install netbeans

Note that installing netbeans will also install the JDK if you do don't have it already installed. This is not the same Java what you were installing in the previous step - the first one is a JRE for Windows, required to run the emulator, while a linux native netbeans will require a linux native JDK. After installing the Netbeans, make sure you have the Mobility plugin also installed. You can check this in the Tools->Plugins submenu as per the screens below

File:Netbeans ME install1.png
Open Tools... Plugins
File:Netbeans ME install2.png
Check installed plugins for Java ME
File:Netbeans ME install3.png
Enable Netbeans distribution if Java ME plugin is missing
File:Netbeans ME install4.png
Update repositories
File:Netbeans ME install5.png
Install mobility plugin

The symlinks

The Nokia SDK 2.0 comes with a device emulator and an IDE (Eclipse). The IDE will run under Wine, but unfortunately something prevents it from seeing the installed SDKs and device emulators and because of that refuses to create a MIDlet project without a device emulator configured. The solution is to use native NetBeans IDE, it can't use the Windows based device emulators directly, but fortunately the emulators have a Open... option in the file menu so we are able to start the Java ME .jar files ourself. (And also Open url... you can use that option to test Web apps on the device native browser!)

To make easier to find the built .jar files from the emulators I made a symlink from the wine environment to my NetBeans installation, like this:

user@dummy:~$ cd .wine/drive_c/
user@dummy:~/.wine/drive_c$ ln -s /home/user/NetBeansProjects

As the SDKs won't integrate with the native NetBeans, you need to add any extra .jar files (for example the Maps API or other Nokia SDK specific libraries) yourself to your project from the Project Properties -> Libraries & Resources tab.

Testing Java apps

Now you should have everything you need. You can test the emulators by creating a Hello World app in NetBeans and then opening the .jar from the emulator.

Series 40 Web apps

As mentioned in the introduction, the Web Apps development environment is available as a native Linux applications. Everything should work fine under Linux using it and you can follow directly any documentation available.

Testing your web apps can be done directly in the IDE, using local or cloud based preview. These are not perfect emulations of the Nokia Browser on the real devices, but as far as I know, the device emulators that come with the Java ME SDKs have the real native browsers installed. It is possible to test Web Apps under the device emulators, copy&paste the URL given by the Web Tools when deploying and use the Open url... option in the emulators.

Conclusion

Now you should be able to develop and test Java ME apps under Linux with the Nokia Series 40 device emulators! Enjoy.

408 page views in the last 30 days.
×