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
Developer
Posts: 672
Registered: ‎12-04-2012
My Device: BlackBerry 8520
My Carrier: Airtel

Warning!: No definition found for exported static routine: .main(String[]) Packaging project MyApplication succeeded (BB7 Java App)

When i try to  create a New Midlet  project and run by following 

 

  1. From the BlackBerry menu, click New > BlackBerry Project.
  2. In the Project name field, type HelloBlackBerry.
  3. In the New BlackBerry Project dialog, select Create new project in workspace.
  4. Under JRE, select Use a project specific JRE and then choose BlackBerry JRE 7.0.0 from the dropdown list.
  5. Click Next.
  6. Click Next.
  7. Select the BlackBerry Application.
  8. Click Finish.

 

 

 

And my code  is follows                       

 

MainMidlet.java

 

 

 

package mypackage;


import java.io.*;
import java.util.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.io.*;
import javax.xml.parsers.*;
import org.xml.sax.*;
import org.xml.sax.helpers.*;

class Channel {    
	public String cName;    
	public String cId;    
	public String cType;
	public String cLanguage;
	public String cImage;
	public String cLink;
	public String cBandwidth;
	public String cCellnapid;
}

class ChannelListHandler extends DefaultHandler {    

	Channel currentChannel;
	private String lastCharacters;   
	
	private Vector channelList;     
	
	public ChannelListHandler() {        
		channelList = new Vector();    
	}     
	
	public Channel[] getChannels() {       
		Channel[] channels = new Channel[channelList.size()];        
		channelList.copyInto(channels);        
		return channels;    
	}
	
	public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {    
		if (qName.equals("channel")) {        
			currentChannel = new Channel();    
			}
		}
	
	public void characters(char[] ch, int start, int length) throws SAXException {    
		lastCharacters = new String(ch, start, length).trim();
		} 
	
	public void endElement(String uri, String localName, String qName) throws SAXException {    
		if (qName.equals("name")) {        
			currentChannel.cName=lastCharacters;    		
		} else if (qName.equals("id")) {        
			currentChannel.cId=lastCharacters;    		
		} else if (qName.equals("type")) {        
			currentChannel.cType=lastCharacters;    		
		} else if (qName.equals("language")) {        
			currentChannel.cLanguage=lastCharacters;    		
		} else if (qName.equals("image")) {        
			currentChannel.cImage=lastCharacters;    		
		} else if (qName.equals("link")) {        
			currentChannel.cLink=lastCharacters;    		
		} else if (qName.equals("bandwidth")) {        
			currentChannel.cBandwidth=lastCharacters;    		
		} else if (qName.equals("cellnapid")) {        
			currentChannel.cCellnapid=lastCharacters;    
			channelList.addElement(currentChannel);
			currentChannel=null;
		}
	}	
}

public class MainMidlet extends MIDlet implements CommandListener, Runnable {     
	private Form form;     
	
	public void startApp() {        
		if (form == null) {            
			form = new Form("Demo");            
			form.addCommand(new Command("Exit", Command.EXIT, 0));            
			form.setCommandListener(this);             
			// start parsing            
			(new Thread(this)).start();        
			}        
		Display.getDisplay(this).setCurrent(form);    
		}     
	
	public void pauseApp() {}     
		
	public void destroyApp(boolean must) {}     
	
	public void commandAction(Command c, Displayable d) {        
		if (c.getCommandType() == Command.EXIT) {            
			notifyDestroyed();        
			}    
		}  
	
	public Image loadImage(String url) throws IOException {
	    HttpConnection hpc = null;
	    DataInputStream dis = null;
	    Image image = null;   
	    try {
	      hpc = (HttpConnection) Connector.open(url);
	      int length = (int) hpc.getLength();
	      byte[] data = new byte[length];
	      dis = new DataInputStream(hpc.openInputStream());
	      dis.readFully(data);	      
	      try {
	    	  image = Image.createImage(data, 0, data.length);
	      } catch (IllegalArgumentException e) {}
	    } catch (Exception e) {            
	    } finally {
	      if (hpc != null) hpc.close();
	      if (dis != null) dis.close();   
	    }
	    return image;
	}
	    
	public void run() {        
		try {            	
			ChannelListHandler handler = new ChannelListHandler();                       
			SAXParser parser = SAXParserFactory.newInstance().newSAXParser();             
			
			Channel[] channels = null;
			HttpConnection con = null;
			InputStream ins = null;
			
			try {
				con = (HttpConnection)Connector.open("http://yupptv.com/mobile/symbianxmlnew.aspx");
				ins = con.openInputStream();           
				parser.parse(ins, handler);
			 } catch (Exception e) {            
				 form.append(e.toString());        
			 }	finally {             		
				 channels = handler.getChannels(); 
				 if (con != null) con.close();
				 if (ins != null) ins.close();
			 }
			
			if (channels != null && channels.length > 0) {
				for (int i = 0; i < channels.length; i++) {
					form.append(channels[i].cName);
					Image image = loadImage(channels[i].cImage);
					if ( image == null ) form.append("\nInvalid image link!\n");
					else form.append(new ImageItem(null, image, ImageItem.LAYOUT_CENTER | ImageItem.LAYOUT_NEWLINE_BEFORE | ImageItem.LAYOUT_NEWLINE_AFTER, ""));
				}
			} else {               
				form.append("(no channels)\n");           
			}
		} catch (Exception e) {            
			form.append(e.toString());        
		}	
	}
}

 

 

and my screen      code is 

 

YuppScreen.java

 

 

package mypackage;

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

/**
 * A class extending the MainScreen class, which provides default standard
 * behavior for BlackBerry GUI applications.
 */
public final class YuppScreen extends MainScreen
{
    /**
     * Creates a new YuppScreen object
     */
    public YuppScreen()
    {        
        // Set the displayed title of the screen       
        setTitle("YuppTV");
    }
}

 

 

 

 

Please help me My MainMidlet.java is  a code of live tv Java app which uses xml parser etc.

 

 

 

 

 

 

 

Developer
Posts: 19,631
Registered: ‎07-14-2008
My Device: Not Specified

Re: Warning!: No definition found for exported static routine: .main(String[]) Packaging project MyApplication succeeded (BB7 Java App)

When you go through the steps you have outlined, the result is a project containing two source files. MyApp and MyScreen.  What do you do with those files?

Developer
Posts: 672
Registered: ‎12-04-2012
My Device: BlackBerry 8520
My Carrier: Airtel

Re: Warning!: No definition found for exported static routine: .main(String[]) Packaging project MyApplication succeeded (BB7 Java App)

MyScreen class is not compulsory for my App .But my App's  main motive is to parse contents conatine d in the

 

xml.aspx or a url and show the  parsed contents like names and images.

 

 

Please guide How  to create such BlackBerry project 

 

 

 

Developer
Posts: 672
Registered: ‎12-04-2012
My Device: BlackBerry 8520
My Carrier: Airtel

Re: Warning!: No definition found for exported static routine: .main(String[]) Packaging project MyApplication succeeded (BB7 Java App)

MyScreen class is not compulsory for my App .But my App's  main motive is to parse contents conatine d in the

 

xml.aspx or a url and show the  parsed contents like names and images.

  

Please guide How  to create such BlackBerry project 

 

Which type of Template should be selected ?

 

 

 

Developer
Posts: 19,631
Registered: ‎07-14-2008
My Device: Not Specified

Re: Warning!: No definition found for exported static routine: .main(String[]) Packaging project MyApplication succeeded (BB7 Java App)

Slightly confused here.

 

When I create the Blackberry project in the way you have described, it automatically creates two source files in the src directory, one called MyApp and one called MyScreen. There is no template specified.  Try your steps again with a new project and see what java source files are created for you.

 

You can of course replace MyScreen with your actual screen, if that is what you want.  But you need to have a main(..) method and an Application instance to run your application, so you should leave MyApp and change it to start whatever processing you need it to.

 

I am also slightly confused at the terminology here/  Are you creating a Midlet or BB specific java application called a RIMLet.  The above is for a RIMLet. 

Developer
Posts: 672
Registered: ‎12-04-2012
My Device: BlackBerry 8520
My Carrier: Airtel

Re: Warning!: No definition found for exported static routine: .main(String[]) Packaging project MyApplication succeeded (BB7 Java App)

Yes Iam trying to build a MIdlet based Live TV Java application

 

 

Yes it worked on Nokia S40 i.e Asha eclipse

 

And the output is as shown

 

for the MiDlet Project containing mainMidlet.java as Java ME MiDlet

 

 

In Nokia Eclipse First I created a MIDlet Project and created a Java ME MIdlet called  MianMIdlet.jav with package name as  mypackage

 

 

and then Run  on simulator   and the out put show the parsed channel images and names  as per my Target

 

 

 

nokiascrshot.jpg

 

 

Developer
Posts: 19,631
Registered: ‎07-14-2008
My Device: Not Specified

Re: Warning!: No definition found for exported static routine: .main(String[]) Packaging project MyApplication succeeded (BB7 Java App)

Sorry not that familiar with MIDLET development.  Can you confirm that you do not want to use any of the Blackberry Ui features - in other words, you will use only the standard Java ME controls that you use on the Nokia application?  If that is what you ant, then I think you will need to add all your source to your project, remove anything that was created by the New Project wizard, and then make sure that Midlet is specified as the Application Type in the BlackBerry App descriptor.

Developer
Posts: 672
Registered: ‎12-04-2012
My Device: BlackBerry 8520
My Carrier: Airtel

Re: Warning!: No definition found for exported static routine: .main(String[]) Packaging project MyApplication succeeded (BB7 Java App)

[ Edited ]

Iam not particular to use only Java Midlet Application    but  gave example of a Java ME App  which gave out put as required  on Nokia Phone.

 

 

 

Ultimately My project should be a Java application and should parse xml.aspx contents like Images, names and Url's.

 

 It can use any UI features like a UI application also.

 

 

 

 

Thanks

 

 

Developer
Posts: 672
Registered: ‎12-04-2012
My Device: BlackBerry 8520
My Carrier: Airtel

Re: Warning!: No definition found for exported static routine: .main(String[]) Packaging project MyApplication succeeded (BB7 Java App)

Iam eagerly waiting for reply to my query

Developer
Posts: 19,631
Registered: ‎07-14-2008
My Device: Not Specified

Re: Warning!: No definition found for exported static routine: .main(String[]) Packaging project MyApplication succeeded (BB7 Java App)

Ij you want to create a modlet, then try the option I suggested in my last post.

 

If you want to create a Rimlet, then you will have re-write the Niokia code Ui specifically for the BlackBerry. 

 

Have a ssearch around to see what other people have said on the differences betweem Rimlets and Midlets.