Critique of J2ME Integration in IDEA

I've been using IDEA for many years for J2SE and J2EE development, and have recently had the opportunity to start using it for J2ME development working here at Nokia.

Let me start by saying that IDEA does many things well in the J2ME world. However, I still think there are a few small changes which could make a huge difference in the usability of the IDE for J2ME projects. So, thanks for all the hard work on getting to this point, great job! The rest of this message will focus on areas for improvement.

The first main area I see for improvement is in the J2ME module configuration. The system is designed to support a single JAR and JAD file combination, as evidenced by the fact that the module configuration only provides for a single JAR/JAD file.

This is flawed, because it requires the developer to structure their project directories according to IDEA's concepts, rather than being flexible enough to conform to the developer's preferred mode of operation.

There are two things which contribute to this situation. The first is that you can not set up a J2ME run/debug target if you do not have a J2ME module. The second is that no two modules may exist in the same directory.

It is possible to configure a simple Java module with a WTK JDK, which enables the developer to set up a project with ant, as long as the developer doesn't want to use the run/debug functionality of IDEA, but this solution does not address a few situations very well.

Consider a project which includes a set of core classes which are both J2ME and J2SE compatible. (This is possible if you restrict your API usage to only those classes and methods which are available in both APIs.) There may then be two sets of classes which provide platform specific support, one for J2SE and one for J2ME. The obvious project structure for this type of project would be as follows

src/common/
src/j2se/
src/j2me/

It is difficult to configure IDEA to have both a J2ME and a J2SE project which both compile the common src, as well as the respective platform specific source.

The other type of project which is difficult to support is the project which includes a number of different MIDlets. As IDEA stands, a J2ME project only supports a single JAR and JAD combination, and you must package all of your MIDlets into this single JAR and JAD.

Often a developer may want to use a common code base to build several different MIDlets, and deploy them as several JAR/JAD combinations. You notice that there is really no reason in a J2ME module to have more than one run/debug target, since the module will only build a single JAR/JAD file containing all the MIDlets in the source tree.

What I would like to see is the three mobile tabs in the module configuration panel moved into a separate MIDlet build target system which allows multiple JAR/JADs to be configured, which will compile, preverify, and package the J2ME MIDlet appropriately.

I would also like to have the ability to place two modules in the same directory.

These two changes would allow both a J2SE module and a J2ME module to be placed in a common directory, to build products for both platforms from the same source tree.

Comments and questions welcome.

--Peter
Nokia SNAP Mobile
http://snapmobile.nokia.com/

3 comments

Hello Peter,

Thank you for your suggestions :)

I'll try to explain why we provide such structures for ME modules. We thought
that if you have a number of modules with dependencies then you will have
one jar/jad per module and at the same time you can share some code base
due to dependencies. E.g. you can have SE module and 2 ME modules with dependencies
on it.

I am sorry but I didn't catch the main point - why such scenario is not sufficient
for your purposes? I must be missing something ... :(

Is it inconvenient to use ant tasks with it? Or ?

Thank you again.

-


Anna Kozlova
JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

I've been using IDEA for many years for J2SE and J2EE development, and
have recently had the opportunity to start using it for J2ME
development working here at Nokia.

Let me start by saying that IDEA does many things well in the J2ME
world. However, I still think there are a few small changes which
could make a huge difference in the usability of the IDE for J2ME
projects. So, thanks for all the hard work on getting to this point,
great job! The rest of this message will focus on areas for
improvement.

The first main area I see for improvement is in the J2ME module
configuration. The system is designed to support a single JAR and JAD
file combination, as evidenced by the fact that the module
configuration only provides for a single JAR/JAD file.


This is flawed, because it requires the developer to structure their
project directories according to IDEA's concepts, rather than being
flexible enough to conform to the developer's preferred mode of
operation.

There are two things which contribute to this situation. The first is
that you can not set up a J2ME run/debug target if you do not have a
J2ME module. The second is that no two modules may exist in the same
directory.

It is possible to configure a simple Java module with a WTK JDK, which
enables the developer to set up a project with ant, as long as the
developer doesn't want to use the run/debug functionality of IDEA, but
this solution does not address a few situations very well.

Consider a project which includes a set of core classes which are both
J2ME and J2SE compatible. (This is possible if you restrict your API
usage to only those classes and methods which are available in both
APIs.) There may then be two sets of classes which provide platform
specific support, one for J2SE and one for J2ME. The obvious project
structure for this type of project would be as follows

src/common/
src/j2se/
src/j2me/
It is difficult to configure IDEA to have both a J2ME and a J2SE
project which both compile the common src, as well as the respective
platform specific source.

The other type of project which is difficult to support is the project
which includes a number of different MIDlets. As IDEA stands, a J2ME
project only supports a single JAR and JAD combination, and you must
package all of your MIDlets into this single JAR and JAD.

Often a developer may want to use a common code base to build several
different MIDlets, and deploy them as several JAR/JAD combinations.
You notice that there is really no reason in a J2ME module to have
more than one run/debug target, since the module will only build a
single JAR/JAD file containing all the MIDlets in the source tree.

What I would like to see is the three mobile tabs in the module
configuration panel moved into a separate MIDlet build target system
which allows multiple JAR/JADs to be configured, which will compile,
preverify, and package the J2ME MIDlet appropriately.

I would also like to have the ability to place two modules in the same
directory.

These two changes would allow both a J2SE module and a J2ME module to
be placed in a common directory, to build products for both platforms
from the same source tree.

Comments and questions welcome.

--Peter
Nokia SNAP Mobile
http://snapmobile.nokia.com/



0

Thanks for the reply.

My point is that the basic assumption is flawed.

You said "We thought that if you have a number of modules with dependencies then you will have one jar/jad per module and at the same time you can share some code base due to dependencies. E.g. you can have SE module and 2 ME modules with dependencies on it."

In order to have one jar/jad per module, I need to have completely separate src directories for each jad/jar. It is often the case that developers want to have a single j2me src tree (and thus j2me module) with multiple jar/jad build targets.

Your suggested SE module fix has a problem, too. When you create a Java module, it builds J2SE code. This means that if you use any J2ME code in your common lib, it won't compile. You also can't add J2ME run/debug targets to a Java module with a WTK set as the JDK. Further, the preverifier doesn't run with this setup, resulting in classes that won't run on J2ME devices.

There's also the issue of cross-platform libraries. I'm speaking specifically about code that is meant to run under both J2SE and J2ME. Even if you create a Java module, and set the JDK to a WTK, the preverifier doesn't run, resulting in classes that won't run on a device.

Here's a sample project directory structure:

project/
...........project.ipr
...........src/
................j2me/
........................com.nokia.* (multiple MIDlets)
................j2se/
.......................com.nokia.*
................common/
.......................com.nokia.*
............test_src/
.........................j2me/
................................com.nokia.* (multiple MIDlets)
.........................j2se/
................................com.nokia.*
.........................common/
......................................com.nokia.*

How can you create a single project with multiple modules to cover all the code, all the various directories both in the project root, and the various subdirectories, and which lets you build multiple jar/jads?

--Peter
Nokia SNAP Mobile
http://snapmobile.nokia.com/

0

Hello Peter,

Thanks for the reply.

My point is that the basic assumption is flawed.

You said "We thought that if you have a number of modules with
dependencies then you will have one jar/jad per module and at the same
time you can share some code base due to dependencies. E.g. you can
have SE module and 2 ME modules with dependencies on it."

In order to have one jar/jad per module, I need to have completely
separate src directories for each jad/jar. It is often the case that
developers want to have a single j2me src tree with multiple jar/jad
build targets.


I don't understand why it is useful ... Could you please provide an example.
It is not easy to support modules with intersected source trees. That's why
I ask.

Your suggested SE module fix has a problem, too. When you create a
Java module, it builds J2SE code. This means that if you use any J2ME
code in your common lib, it won't compile. You also can't add J2ME
run/debug targets to a Java module with a WTK set as the JDK. Further,
the preverifier doesn't run with this setup, resulting in classes that
won't run on J2ME devices.


We've preverify all dependant modules thus J2SE code must be preverified
with WTK preverifier. If not - it is a bug.
You are right you can't assign a run/debug configuration with Java module
but why do you need so?

There's also the issue of cross-platform libraries. I'm speaking
specifically about code that is meant to run under both J2SE and J2ME.
Even if you create a Java module, and set the JDK to a WTK, the
preverifier doesn't run, resulting in classes that won't run on a
device.


How do you use this libraries? Why they are SE? How can you build common/
in both SE and ME way simultaneously? ;)

In your examle I suggest the following structure
ME
j2me
SE
j2se
Common
common
where ME depends on common.

If you need SE depends on common then I just do not understand how can it
work. Can you explain me? Thank you

Here's a sample project directory structure:

project/
..........project.ipr
..........src/
...............j2me/
.......................com.nokia.* (multiple MIDlets)
...............j2se/
......................com.nokia.*
...............common/
......................com.nokia.*
...........test_src/
........................j2me/
...............................com.nokia.* (multiple MIDlets)
........................j2se/
...............................com.nokia.*
........................common/
.....................................com.nokia.*
How can you create a single project with multiple modules to cover all
the code, all the various directories both in the project root, and
the various subdirectories, and which lets you build multiple
jar/jads?
--Peter
Nokia SNAP Mobile
http://snapmobile.nokia.com/


Thank you for your attention. Possible usecases for J2ME are very interesting
for us. Thank you again.


0

Please sign in to leave a comment.