EzDevInfo.com

java-me interview questions

Top java-me frequently asked interview questions

What mobile platform should I start learning? [closed]

What mobile platform should I start learning? What matters is:

  • ease
  • popularity of the platform
  • low cost of the SDK and actual handheld

Source: (StackOverflow)

Creating a Mobile Programming Language

I'm thinking about creating a small language that is very easy to type on a mobile phone (J2ME), What is the more appropriate language to implement in order to run it inside a mobile phone (j2me always)? Appropriate meaning, small/easy syntax, easy to type in a mobile phone.

Is it lisp? Some sort of Basic/Python/Ruby (I think not...)? Or another new (can you propose a new syntax?)?


Source: (StackOverflow)

Advertisements

Develop Blackberry apps using native API or J2ME?

We're about to build a Blackberry application but would love some input on whether to implement using J2ME (MIDlet based) or Blackberry native (UIApplication).

I understand some of the tradeoffs. J2ME will be more flexible if we want to port the app to other devices. RIM has better support for Blackberry native.

The place I'm still lacking information, though, is on the UI side. We want to build an app that has a great user experience, and one that looks like other apps BB users are accustomed to. Can we do this if we go the J2ME route?

Apologies for the somewhat subjective and less technical nature of the question.


Source: (StackOverflow)

Difference between Java SE/EE/ME?

Which one should I install when I want to start learning Java? I'm going to start with some basics, so I will write simple programs that create files, directories, edit XML files and so on, nothing too complex for now.

I guess Java SE (Standard Edition) is the one I should install on my Windows 7 desktop. I already have Komodo IDE which I will use to write the Java code.


Source: (StackOverflow)

How to convert String to JSONObject in Java

I have String variable called jsonString:

{"phonetype":"N95","cat":"WP"}

Now I want to convert it into JSON Object. I searched more on Google but didn't get any expected answers...


Source: (StackOverflow)

Convert a JSON string to object in Java?

Is there a way in Java/J2ME to convert a string, such as:

{name:"MyNode", width:200, height:100}

to an internal Object representation of the same, in one line of code?

Because the current method is too tedious:

Object n = create("new");
setString(p, "name", "MyNode");
setInteger(p, "width", 200);
setInteger(p, "height", 100);

Maybe a JSON library?


Source: (StackOverflow)

Extract source code from .jar file

Is there a way to extract the source code from an executable .jar file (Java ME)? Any help will be appreciated.


Source: (StackOverflow)

Packaging Blackberry OAuth app throwing error

I am creating an application that will post a link onto Twitter. The following code refuses to package up for me, throwing the following error:

Error: Cannot run program "jar": CreateProcess error=2, The system cannot find the file specified

Here is the code:

public class ShowAuthBrowser extends MainScreen implements OAuthDialogListener
{
    private final String CONSUMER_KEY = "<Consumer>";   
    private final String CONSUMER_SECRET = "<Secret>";
    private LabelField _labelStutus;
    private OAuthDialogWrapper pageWrapper = null;
    public StoreToken _tokenValue;
    public BrowserField b = new BrowserField();
    Manager _authManager;
    Manager _pinManager;
    ButtonField authButton;
    TextField authPin;

    public ShowAuthBrowser()    
    {   
        _authManager = new VerticalFieldManager(NO_VERTICAL_SCROLL |
                                                NO_VERTICAL_SCROLLBAR);
        _pinManager = new HorizontalFieldManager(NO_VERTICAL_SCROLL |
                                                 NO_VERTICAL_SCROLLBAR);
        authButton = new ButtonField("OK");
        authPin = new TextField(Field.EDITABLE);
        _authManager.add(_labelStutus );
        _authManager.add(b);

        _pinManager.add(authButton);
        _pinManager.add(authPin);


        pageWrapper = new BrowserFieldOAuthDialogWrapper(b,CONSUMER_KEY,
                            CONSUMER_SECRET,null,this);
        pageWrapper.setOAuthListener(this);     

        add(_pinManager);
        add(_authManager);

        authButton.setChangeListener( new FieldChangeListener( ) {
            public void fieldChanged( Field field, int context ) {
                if( field == authButton ) {
                       doAuth(authPin.getText());
                }
            }
        } );

    }

    public void doAuth( String pin )
    {
        try
        {
            if ( pin == null )
            {
                pageWrapper.login();
            }
            else
            {
                this.deleteAll();
                add(b);
                pageWrapper.login( pin );
            } 

        }
        catch ( Exception e )
        {
            final String message = "Error logging into Twitter: " + 
                                                e.getMessage();
            Dialog.alert( message );
        }           
    }

    public void onAccessDenied(String response ) {

        updateScreenLog( "Access denied! -> " + response );

    }

    public void onAuthorize(final Token token) {

        final Token myToken = token;
        _tokenValue = StoreToken.fetch();
        _tokenValue.token = myToken.getToken();
        _tokenValue.secret = myToken.getSecret();
        _tokenValue.userId = myToken.getUserId();
        _tokenValue.username = myToken.getUsername();
        _tokenValue.save();

        UiApplication.getUiApplication().invokeLater( new Runnable() {

            public void run() {
                deleteAll();
                Credential c = new Credential(CONSUMER_KEY, 
                                              CONSUMER_SECRET, 
                                              myToken);
                PostTweet tw = new PostTweet();
                String message="Testing BB App";
                boolean done=false;
                done=tw.doTweet(message, c);
                if(done == true)
                {
                    Dialog.alert( "Tweet succusfully..." );
                    close();    
                }
            }
        });

    }

    public void onFail(String arg0, String arg1) {
        updateScreenLog("Error authenticating user! -> " + arg0 + ", " + arg1);
    }

    private void updateScreenLog( final String message )
    {
        UiApplication.getUiApplication().invokeLater( new Runnable() {

            public void run() {
                _labelStutus.setText( message );                
            }
        });
    }
}

The odd thing is, if I remove the following lines, it packages just fine:

authButton.setChangeListener( new FieldChangeListener( ) {
        public void fieldChanged( Field field, int context ) {
            if( field == authButton ) {
                   doAuth(authPin.getText());
            }
        }
    } );

Any help would be appreciated as I really need the field listener attached to this screen.

With code like authButton.setChangeListener(null), it does package successfully however I do need code with FieldChangeListener to do something.


Source: (StackOverflow)

How do I convert between ISO-8859-1 and UTF-8 in Java?

Does anyone know how to convert a string from ISO-8859-1 to UTF-8 and back in Java?

I'm getting a string from the web and saving it in the RMS (J2ME), but I want to preserve the special chars and get the string from the RMS but with the ISO-8859-1 encoding. How do I do this?


Source: (StackOverflow)

Android how to get access to raw resources that i put in res folder?

In J2ME, I've do this like that: getClass().getResourceAsStream("/raw_resources.dat");

But in android, I always get null on this, why?


Source: (StackOverflow)

Difference between volatile and synchronized in JAVA

I am wondering at the difference between declaring a variable as volatile and always accessing the variable in a synchronized(this) block in JAVA (particularly J2ME)?

According to this article http://www.javamex.com/tutorials/synchronization_volatile.shtml there is a lot to be said and there are many differences but also some similarities.

I am particularly interested in this piece of info:

...

  • access to a volatile variable never has the potential to block: we're only ever doing a simple read or write, so unlike a synchronized block we will never hold on to any lock;
  • because accessing a volatile variable never holds a lock, it is not suitable for cases where we want to read-update-write as an atomic operation (unless we're prepared to "miss an update");

What do they mean by read-update-write? Doesn't a write also an update or do they simply mean that the update is a write that depends on the read info?

Most of all, when is it more suitable to declare variables volatile than access them through synchronized? Is it a good idea to use volatile for variables that depend on input? For instance, there is a variable called render that is read through the rendering loop and set by a keypress event?


Source: (StackOverflow)

Best way to really grok Java-ME for a C# guy [closed]

I've recently started developing applications for the Blackberry. Consequently, I've had to jump to Java-ME and learn that and its associated tools. The syntax is easy, but I keep having issues with various gotchas and the environment.

For instance, something that surprised me and wasted a lot of time is absence of real properties on a class object (something I assumed all OOP languages had). There are many gotchas. I've been to various places where they compare Java syntax vs C#, but there don't seem to be any sites that tell of things to look out for when moving to Java.

The environment is a whole other issue all together. The Blackberry IDE is simply horrible. The look reminds me Borland C++ for Windows 3.1 - it's that outdated. Some of the other issues included spotty intellisense, weak debugging, etc... Blackberry does have a beta of the Eclipse plugin, but without debugging support, it's just an editor with fancy refactoring tools.

So, any advice on how to blend in to Java-ME?


Source: (StackOverflow)

J2ME/Android/BlackBerry - driving directions, route between two locations

On Android 1.0 there was a com.google.googlenav namespace for driving directions:
Route - Improved Google Driving Directions
But in newer SDK it was removed by some reason...
Android: DrivingDirections removed since API 1.0 - how to do it in 1.5/1.6? On BlackBerry there is also lack of APIs for such stuff:
how to find the route between two places in Blackberry?

csie-tw gives a workaround (query gmaps for kml file and parse it):
Android - Driving Direction (Route Path)
Also Andrea made a DrivingDirections helper classes for Android.
I wrote a little helper for this functionality, in j2me, so I would like to share my samples on Android and BlackBerry.

UPDATE
As it was stated in comments, it's not officially allowed Google Maps APIs Terms of Service :

Google Maps/Google Earth APIs Terms of Service
Last updated: May 27, 2009
...
10. License Restrictions. Except as expressly permitted under the Terms, or unless you have received prior written authorization from Google (or, as applicable, from the provider of particular Content), Google's licenses above are subject to your adherence to all of the restrictions below. Except as explicitly permitted in Section 7 or the Maps APIs Documentation, you must not (nor may you permit anyone else to):
...
10.9 use the Service or Content with any products, systems, or applications for or in connection with:
(a) real time navigation or route guidance, including but not limited to turn-by-turn route guidance that is synchronized to the position of a user's sensor-enabled device;

and may be disabled for certain apps (somehow, at least on Android)... From Geocode scraping in .NET conversation:

This is not allowed by the API terms of use. You should not scrape Google Maps to generate geocodes. We will block services that do automated queries of our servers.

Bret Taylor
Product Manager, Google Maps

Would be grateful for any alternatives and/or suggestions!
Thanks!


Source: (StackOverflow)

Eclipse IDE- Add jar? Add External jar? Add Library?

I want to integrate TwitterAPIME to my Blackberry project. I have 3 Jar files provided by TwitterAPIME. I am not sure how to link these 3 Jar files to my project.

My basic doubts are

What is an External Jar ? What is a Library ?

What's the difference between Adding jar, Adding External jar or Adding Library ?


Source: (StackOverflow)

J2ME Polish Application icon defaulting

I have a problem in a J2ME Polish app where basically we have 2 icons showing for the app (the menu icon and the in-app icon that shows up top).

If I compile with a single icon and set it in the build.xml file it loads it to both sides, although since the menu icon needs to be bigger than the in-app icon, the last one looks extremelly zoomed in.

When I do as stated in the docs and set the resources path in the build.xml with subdirectories on, if I only set a 24x24 icon, the in-app icon gets the new image but the menu icon doesn't. If I then set an icon and a 24x24 icon, it uses the other one as default for both areas.

Does anyone know how I can handle this?

PS: the test rig for this build is a Nokia N70, so if anyone knows the dimensions for the menu icon, I'd really appreciate the tip.

in the Nokia wiki, it states 24x24, but that's only for the in-app icon, not the menu one.


Source: (StackOverflow)