Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
xh7000
Posts: 24
Registered: ‎07-13-2011
My Device: 9780
My Carrier: mtn

Back to square 1

Sorry - I'm a beginner and I am stuck.  Below is a very basic java program cut and paste from a web site.  I have compiled a number of other applications that I have copied and modified - but this one has me stuck.

 

The error is in the line - import  net.rim.device.api.ui.container.MainScreen;

 

What am I missing ?

 

-------------------------------------------------------------------------------------------------------------------

 

import  net.rim.device.api.ui.UiApplication;

public class FirstBlackBerryApp extends UiApplication
{
    public static void main( String[] inArgs )
  {
        FirstBlackBerryApp bbApp = new FirstBlackBerryApp();
        bbApp.enterEventDispatcher();
  }
   
    public FirstBlackBerryApp()
    {
    }
   
    public void activate()
     {
       this.pushScreen( new FirstBlackBerryScreen());
     }
}

 

 


import  net.rim.device.api.ui.container.MainScreen;

public  class FirstBlackBerryScreen extends MainScreen
{
    public  FirstBlackBerryScreen()
    {
        super();
        this.initialize();
    }
   
    private void    initialize()
     {
        this.setTitle( "First BlackBerry App!" );
     }
}

 

Please use plain text.
Contributor
rafabas
Posts: 14
Registered: ‎09-20-2011
My Device: Developer
My Carrier: Vodafone

Re: Back to square 1

I suppose that you have all the code in one only file, and the imports need to be infront of any class declaration, so you obtain a compiler error: "class or interface expected"

 

You can try to split your code in two files (FirstBlakBerryApp.java and FirstBlackBerryScreen.java) each with the declaration of one of your classes, or you can make slight modifications to compile without errors.

 

 

 

 

import  net.rim.device.api.ui.UiApplication;
import  net.rim.device.api.ui.container.MainScreen;

public class FirstBlackBerryApp extends UiApplication
{
    public static void main( String[] inArgs )
    {
        FirstBlackBerryApp bbApp = new FirstBlackBerryApp();
        bbApp.enterEventDispatcher();
    }
   
    public FirstBlackBerryApp()
    {
    }
   
    public void activate()
     {
       this.pushScreen( new FirstBlackBerryScreen());
     }    
     
    public  class FirstBlackBerryScreen extends MainScreen
    {
        public  FirstBlackBerryScreen()
        {
            super();
            this.initialize();
        }
    
        private void initialize()
        {
            this.setTitle( "First BlackBerry App!" );
        }
    }      
}

 

 

Please use plain text.
Contributor
xh7000
Posts: 24
Registered: ‎07-13-2011
My Device: 9780
My Carrier: mtn

Re: Back to square 1

Thanks for the fast reply

 

Much appreciated

 

Brian

Please use plain text.