adding icon to your MIDlet

Hello, this topic is also not very complicated, so the post will be quite short.
We have to remember about some rules before we add icon to a MIDlet:

  • Only PNG’s are allowed
  • icon’s size is not standarized
  • some phones will expand smaller icons, some won’t
  • the icons that are to big might be shrinked or cut to smaller, we can’t decide
  • I recommend using size 32×32, it is smaller than most phones can hold, so at least we can be sure, that it won’t be cut
  • icon files, if we want to reffer to it as: “/icon.png” should be placed in src directory in project’s path I think it’s the best way to do this (this file will be automatically added to newly created JAR file)
  1. After starting Netbeans we go as before to project’s properties, here we open “Application Descriptor” again, then we select second tab:
  2. Now, after choosing “Edit…” we can select file:
  3. Next, we have to add appropriate attribute to our JAD and manifest. Let’s click “Add…”, automatically first to add will be icon attribute:
  4. At last you can run this MIDlet in the emulator (or upload to your mobile). You should see icon you have selected for your app.

converting JARs into JADs using Jadmaker

This thing is not very complicated. Of course now we know how those files are created and we can do this automatically, but there is a better way.

  1. To convert file JAR into JAD download program called JADMaker it doesn’t require installation (the best is to unrar it into directory)
  2. Now we run program, and drag JAR file onto the window
  3. In the folder where there was JAR file now we have approperiate JAD
  • You can directly drag & drop JARs onto the JADMaker icon
  • Program allows you to convert multiple files at once, just mark what you need and drag&drop them.
  • Option “Enable Explorer Contex-Menu extension” allows you to convert files from right click context menu:

modyfing JAD files from Netbeans

As I promised, I’m posting small tutorial how to change application’s description (automatically generated JAD and manifest) using Netbeans.

  1. After right-clicking on the project name choose “Properties”:
  2. Next, goto option “Application Descriptor”:
  3. Here we have ability to add/modify/remove program’s properties that will be put into generated JAD and manifest.
  4. After clicking “Add” we can select attribute from the list, so we don’t have to remember all of them.

In the next post I’ll write how to add and set MIDlet’s icon.

JAD and JAR files

Dzisiejszy post będzie podzielony na 2 części, część pierwsza dotyczyć będzie plików JAD, a druga plików JAR.

Część I

JAD oznacza Java Application Descriptor, jest to specjalny plik przygotowywany (najczęściej) przed IDE w procesie budowania projektu i służy, jak nazwa wskazuje, do opisu pliku zawierającego samą aplikację. Plik JAD zawiera między innymi:

  • informacje o rozmiarze aplikacji
  • jej nazwę
  • wersję
  • wydawcę (autora)
  • informacje o ikonie
  • komentarz
  • informacje o wymaganej wersji MIDP / CLDC
  • w dalszej części posta znajdziesz link do tabeli z wyszczególnionymi opcjami

Najbardziej docenią go użytkownicy, którzy chcą zainstalować program poprzez internet, dzięki temu, że ściągną tylko plik JAD, mogą oni najpierw zobaczyć rozmiar właściwego pliku i go pobrać lub zrezygnować gdy ten rozmiar jest za duży (np. ze względu na koszty transferu danych). Plik jad musi wskazywać położenie pliku jar (jako ścieżkę względną, np. HelloMIDlet.jar, lub jako położenie w sieci np. example.com/HelloMIDlet.jar)

Część II

JAR oznacza Java Archive, jest to tak naprawdę zwykłe archiwum (możesz sprawdzić to próbując je rozpakować zwykłym programem, którego używasz na co dzień). Zawiera ono w sobie skompilowane do bytecodu (pliki *.class) klasy programu, pliki pomocnicze (np. ikony, grafiki). Ważnym elementem tego pliku jest tzw. plik manifestu. Posiada on składnię podobną do pliku JAD i zawiera podobne informacje. Plik ten znajduje się w folderze META-INF i nazywa się MANIFEST.MF.

Tabela zawierająca nazwy atrybutów i informacje gdzie mogą(May)/muszą(Must) wystąpić:

Attribute

Manifest

JAD

MIDlet-Name

Must

Must

MIDlet-Version

Must

Must

MIDlet-Vendor

Must

Must

MIDlet-Jar-URL


Must

MIDlet-Jar-Size


Must

MIDlet-Install-Notify

May

May

MIDlet-Delete-Notify

May

May

MIDlet-Delete-Confirm

May

May

MIDlet-Info-URL

May

May

MIDlet-Description

May

May

MIDlet-Icon

May

May

MicroEdition-Profile (1)(2)

Must

Must

MicroEdition-Configuration (1)(3)

Must

Must

MIDlet- (1)(4)

Must

Must

MIDlet-Push- (5)

May

May

MIDlet-Data-Size

May

May

MIDlet-Permissions

May

May

MIDlet-Permissions-Opt

May

May

pobrane ze strony: http://developers.sun.com/mobility/midp/ttips/getAppProperty/

Nam jednak będą wystarczały te podstawowe atrybuty o których wspomniałem na początku.
Aby nauczyć się “składni” pliku JAD i manifestu najlepiej podglądnij te 2 pliki w naszej pierwszej aplikacji.

Niedługo dopiszę informacje jak zmieniać te właściwości z poziomu środowiska (co jest o wiele łatwiejsze i przyjemniejsze).

Today’s post will be divided into 2 parts, first will cover JAD files and second will be about JARs.

Part I

JAD stands for Java Application Descriptor, it’s a special file prepared (mostly) by IDE in the process of building/compiling project. It’s used (as the name indicates) to describe file containing application (JAD doesn’t contain application). JAD’s are used to set/provide information about program’s attributes like:

  • information about size
  • application’s name
  • version
  • vendor (author)
  • icon path
  • comment
  • MIDP/CLDC requirements

It will be mostly appreciated by users, who want for example to install program over the internet. They need only to download JAD, than they’ll be able to see programs requirements and size, and decide if they really want do download it or resigin (for example if data transfer costs are to high).

JAD file has to provide informaiton about application’s path, it might be only relative path (like: HelloMIDlet.jar) or location in the web (like: example.com/HelloMIDlet.jar) then jar file will be downloaded (of course after confirmation from user).

Part II

JAR stands for Java Archive, it’s really normal zip archive (you can unzip it using your normal program that you use everyday). It contains compiled versions of your classes (files *.class), additional files (like: graphics, icons, text files). It has also very important file MANIFEST.MF in
META-INF directory. This file is very similar to JAD.

Table containing all attributes names and information where it might/must occur:

Attribute Manifest JAD
MIDlet-Name Must Must
MIDlet-Version Must Must
MIDlet-Vendor Must Must
MIDlet-Jar-URL Must
MIDlet-Jar-Size Must
MIDlet-Install-Notify May May
MIDlet-Delete-Notify May May
MIDlet-Delete-Confirm May May
MIDlet-Info-URL May May
MIDlet-Description May May
MIDlet-Icon May May
MicroEdition-Profile (1)(2) Must Must
MicroEdition-Configuration (1)(3) Must Must
MIDlet- (1)(4) Must Must
MIDlet-Push- (5) May May
MIDlet-Data-Size May May
MIDlet-Permissions May May
MIDlet-Permissions-Opt May May

from: http://developers.sun.com/mobility/midp/ttips/getAppProperty/

For us only some attributes will be useful (they are listed in part II). To learn syntax of files JAD and manifest you can just look at them in our first application.

Soon, I’ll be writing about how to set and modify application’s attributes within Netbeans, what is much easier and pleasant.

howto: first mobile application in Netbeans

Today I’ll show how to create new mobile app project using Java Mobile and Netbeans (if you don’t have Netbeans installed, read my recent post). If you have installed IDE properly, you should see this screen:
To start new project click:Next, choose options responding to what kind of project you want to create. Select “Java ME” and “Mobile Application”Now, choose project name and path. Also you need to select options “Set as Main Project” (about it later), and “Create HelloMIDlet” which is responsible for creating default MIDlet (Java Mobile application for mobile phone). You can see, that project folder has been set automatically.


On the next screen don’t change options “Emulator Platform” and “Device”. It is important to change device configuration and profile. Change CLDC to 1.0 and MIDP to 2.0 (see image). It will let us to run app on much greater number of phones (this issue was covered in earlier posts).

Don’t change anything on next screen and press “Finish”.

Congratulations! You have just created your first mobile app project, automaticaly thanks to option “Create HelloMIDlet” Hello midlet was created :) and it’s ready to run and be copied on mobile phone.

IDE look after clicking “Finish”:

Now, you can jump beetween code vieves by using thoose buttons.

  • Source lets you edit source code.
  • Screen lets you edit application view in easy-to-use interface. I don’t recommend this method. Of course it’s very easy in the beginning, but later, if you have to do some tiny modyfication, you’ll need to use it again – code created by this editor cannot be modified in “Source” tab. It’s easier in the beginning as I said, but after gaining some experience you’ll find everything easier to do in “Source” tab.
  • Flow is used to project, edit, view, or set relationships beetween application’s screens.
  • Analyzer - let’s leave this for later.

Becouse during creating project we have set option “Set as main project”, now we can only click button marked on screenshot (or use shortcut F9) to build and run our project.

Now we can “play” with our program in emulator window. Files ready to upload on your mobile are located in:

D:\java\Hello\dist

in my case, and generally:

[project location] / [project name] /dist/ [filename].jad and .jar

filename is by default set to project name.

I would like to encourage you to experiment with this app and IDE’s options. Soon I’m going to post information on how to edit options in JAD file (this file is read by telephone to set information about program, like name, vendor, version).

Java Mobile – introduction

Firstly, quick introduction: JavaMe (also known as: j2me, jme, java me, Java Mobile Edition, …) is a special version of Java (in fact it is “frozen” Java 1.3, maybe with some features) dedicated to devices with low computing power, we distinguish two configurations: CDC (palmtops, more powerful phones, …), CLDC (Connected Limited Device Configuration) – baisicaly every other phone.

Configurations include basic classes, and they are extended by profiles (MIDP – Mobile Information Device Profile), all new phones should handle MIDP version 2.0 (newer 2.1). Profiles provide classes to:

  • handle screen (high and low level)
  • multimedia features
  • better connectivity (eg. HTTPS)
  • and many more

Next, phone can also provide additional APIs, called JSR. JSRs extend phone’s powers (for example by allowing you to use bluetooth), they are not included in CLDC nor MIDP. Every JSR has it’s own number, so they are easly identified (bluetooth is called JSR-82).

All programs I’m going to write require MIDP version 2.0. That doesn’t mean you wont be able to run them on older phones, but you may not be able to use things that are extended in version 2.0, for example you won’t hear background music playing, or you won’t be able to initiate call inside application.

When writing program for mobile phone, you should remember, that it’s manufacturer is responsible for delivering appropriate runtime environment (JVM). Sometimes it is not written according to specification delivered by Sun. I have noticed, that Nokia models have some problems with some elements of GUI. I have also tested Samsung’s and Sony Ericsson’s, and didn’t have any problems with them (I have no possibility to chceck it on other phones, so I don’t know how it is with for example Motorola).

You can find additional info on wikipedia (as usual):


At most on Friday I’ll post information how to start new project in Netbeans, and start writing programs:)

basics part 2, IDE

Hi,
Before we go to writing code, we have to get IDE (Integrated Development Environment). There are many different IDE’s for Java, further information, and list of IDE’s can be found there: http://www.apl.jhu.edu/~hall/java/IDEs.html#Java-IDEs and http://mindprod.com/jgloss/ide.html. I recommend you to use Netbeans, it’s very good for beginners, and also for advanced users. It’s very good integrated with JavaME features (soon about it), easy to use, has good system of plugins and works very stable. Let’s move to installation:

  1. go to: http://www.netbeans.org/downloads/index.html
  2. I recommend to download option “Java”, click “download” button below
  3. installer should search and find your Java version installed on your system, if not set these paths manually
  4. during installation disable “GlassFish”, “Apache Tomcat”, and “Java Enterprise”
  5. later you can set installation directory and you can register your version of Netbeans (this requires account on Sun developer network)

In next post I will write more about JavaME, we are going write our first mobile application.