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
krishnanmurari
Posts: 80
Registered: ‎06-06-2011
My Device: bold 9000
My Carrier: airtel
Accepted Solution

Error on trying to add new code into my project

[ Edited ]

Hi all,

 

When i try to run my code after adding some codes like tolltip or threads in certain screens for a exsisting project, it gives an error as:

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

Packaging project My Address failed (took 4.483 seconds) 

 

Where as when i remove those codes and try to run then it says Packaging project successfull.  

the above error doesnot come when i append certain classes it appears only when i append certain other classes.

 

can anyone help me out here.And do let me know if you are not able to understand the problem.

 

all idea are welcomed, even if it is outside the box.

 

thanks all

Krishnan 

 

 

Please use plain text.
Developer
krishnanmurari
Posts: 80
Registered: ‎06-06-2011
My Device: bold 9000
My Carrier: airtel

Re: Error on trying to add new code into my project

When i am trying to add this below code the error is appearing.

please help.

 

UiApplication.getUiApplication().invokeLater(new Runnable() {public void run() {UiApplication.getUiApplication().pushScreen(new progressscreen());}});

 

 

Please use plain text.
Developer
ankityadav4u
Posts: 231
Registered: ‎03-16-2011
My Device: 9700, 9550, and JDE
My Carrier: AIRTEL, BSNL

Re: Error on trying to add new code into my project

just add jdk's bin folder's  path into environment .............


available on: Monday to Friday, Indian standard (day) time : )
  • Give kudos by clicking on the star icon to say "Thanks!" if you feel this response is helpful.
  • Click "Accept as Solution" if this post was what you needed. so that people who are trying to help will not waste their time reading a thread where no help is needed.

Please use plain text.
Trusted Contributor
hardikhamar
Posts: 159
Registered: ‎02-17-2011
My Device: Not Specified

Re: Error on trying to add new code into my project

[ Edited ]

 

 

 

for example :

 

C:\Program Files\Research In Motion\BlackBerry JDE 4.6.0\bin

 

set ur jdk  path in environment varible of property

Please use plain text.
Developer
krishnanmurari
Posts: 80
Registered: ‎06-06-2011
My Device: bold 9000
My Carrier: airtel

Re: Error on trying to add new code into my project

tried that it still giving me the same error.

 

and once i comment the last appended code from it then it works perfectly fine.

 

the same line of code i have used in the earlier screens then that screen works perfectly fine.

 

i googled it for the packages but none of them are helping. if you want i can show the code

Please use plain text.
Trusted Contributor
hardikhamar
Posts: 159
Registered: ‎02-17-2011
My Device: Not Specified

Re: Error on trying to add new code into my project

if u do not get solution then post ur code.

Please use plain text.
Developer
krishnanmurari
Posts: 80
Registered: ‎06-06-2011
My Device: bold 9000
My Carrier: airtel

Re: Error on trying to add new code into my project

I have two screen in which i am using the same code of threads to be more precise uiapplication.getuiapplication.invokelater code.

 

The first screen where the code works is as follows:-

 

In the bellow code the underlined and bold lines are the one that i have inserted for threads and tryin tho implement the progress screen.

 

package com.address.active;

import java.util.Vector;

import com.address.bussinesslogic.MyAddressParser;
import com.address.bussinesslogic.ReadCode;
import com.address.bussinesslogic.SaxHandlerRC;
import com.address.bussinesslogic.TransactionStatus;
import com.address.bussinesslogic.ValueSetterRC;

import net.rim.device.api.system.Bitmap;
import net.rim.device.api.system.Display;
import net.rim.device.api.system.KeypadListener;
import net.rim.device.api.ui.DrawStyle;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.TouchEvent;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.BitmapField;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.ListField;
import net.rim.device.api.ui.component.ListFieldCallback;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;

public class Service extends MainScreen implements ListFieldCallback,FieldChangeListener {
	Font myFont =null;
	private BitmapButtonField btn1,btn2,btn3,btn4,btn5,btn6;
	private Vector _listElements;
    private ColouredListField colourList;
    ValueSetterRC valuesettertrc;
    Vector types;
    MyTooltip _tooltip;
    int temp;
    public static String ParentId=null,ServiceName=null;
	public Service()
	{
		super(NO_VERTICAL_SCROLL);
		if(Display.getWidth()>360)
		{
		myFont = Font.getDefault().derive(Font.PLAIN, 16);
	   
		}
		else
		{
			myFont = Font.getDefault().derive(Font.PLAIN, 12);
	    
		}
int spacing=(Display.getWidth()-230)/6;
		
		LabelFieldWhite label=new LabelFieldWhite("Service Provider");
		int mar=(30-label.getPreferredHeight())/2;
		label.setMargin(mar, 0, mar, 5);
		
		LabelFieldWhite label1=new LabelFieldWhite("My Address");
		label1.setMargin(mar, 5, mar, 0);	
		
		BitmapField bitmap=new BitmapField(Bitmap.getBitmapResource("logo.png"));
		int mar2=(30-bitmap.getPreferredHeight())/2;
		bitmap.setMargin(mar2, 5, mar2, Display.getWidth()-15-label.getPreferredWidth()-label1.getPreferredWidth()-bitmap.getPreferredWidth());
					
		HorizontalField header=new HorizontalField("br1.png",Display.getWidth(),30);
		header.add(label);
		header.add(bitmap);
		header.add(label1);
		
		this.add(header);
		
		btn1 = new BitmapButtonField(Bitmap.getBitmapResource("icon1.png"),Bitmap.getBitmapResource("icon1H.png"),"",4);;
	    HorizontalField hori=new HorizontalField("tab bar.png",Display.getWidth(),btn1.getPreferredHeight()+20);
	    btn1.setMargin(10, spacing, 10, spacing);
	    btn1.setChangeListener(this);
	    hori.add(btn1); 
	    
	    btn2 = new BitmapButtonField(Bitmap.getBitmapResource("icon2.png"),Bitmap.getBitmapResource("icon2H.png"),"",4);
	    btn2.setMargin(10, 0, 10, spacing);
	    btn2.setChangeListener(this);
	    hori.add(btn2);
	    
	    btn3 = new BitmapButtonField(Bitmap.getBitmapResource("icon3.png"),Bitmap.getBitmapResource("icon3H.png"),"",4);
	    btn3.setMargin(10, 0, 10, spacing);
	    btn3.setChangeListener(this);
	    hori.add(btn3);
	    
	    btn4 = new BitmapButtonField(Bitmap.getBitmapResource("icon4.png"),Bitmap.getBitmapResource("icon4H.png"),"",4);;
	    btn4.setMargin(10, 0, 10, spacing);
	    btn4.setChangeListener(this);
	    hori.add(btn4);
	    
	    btn5 = new BitmapButtonField(Bitmap.getBitmapResource("icon5.png"),Bitmap.getBitmapResource("icon5H.png"),"",4);

	    btn5.setMargin(10, 0, 10, spacing);
	    btn5.setChangeListener(this);
	    hori.add(btn5);
	    
	    btn6 = new BitmapButtonField(Bitmap.getBitmapResource("icon6.png"),Bitmap.getBitmapResource("icon6H.png"),"",4);
	    btn6.setMargin(10, 0, 10, spacing);
	    btn6.setChangeListener(this);
	    hori.add(btn6);
	    
	    this.add(hori);
	    
	    valuesettertrc = SaxHandlerRC.sitesListsecond1;
	    Vector array = valuesettertrc.getTypedescarr();
		_listElements  = new Vector(array.size(), 1);
		types = valuesettertrc.getTypeArraylist();
        colourList = new ColouredListField(false);
        colourList.setRowHeight(44);
		colourList.setCallback(this);


		    for(int count = 0; count<array.size(); count++)
		    {
		    
		       colourList.insert(count);
		       this.insert(array.elementAt(count), count);
		       
		    }

		    LabelField la=new LabelField("Lorem ipsum dolor sit amit, et anim quis nostored",LabelField.USE_ALL_WIDTH | DrawStyle.HCENTER);
		    la.setFont(myFont);
		    la.setMargin(30, 20, 30, 20);
		    colourList.setMargin(0, 0, 0, 0);
		    VerticalFieldManager secondary = new VerticalFieldManager(VERTICAL_SCROLL);
		    this.add(la);
		    secondary.add(colourList);
		    this.add(secondary);
		    focus();
		    setbtnfocus();
	}
	
	public void focus()
	{
		btn2.setFocus();
	}
	
	public Object get(ListField list, int index) 
	{
		 return _listElements.elementAt(index);
	} 
	public int indexOfList(ListField list, String p, int s) 
	{ 
	    return _listElements.indexOf(p, s); 
	} 
	public int getPreferredWidth(ListField list) 
	{ 
	    return Display.getWidth(); 
	}
	public void drawListRow(ListField listField, Graphics graphics,
		int index, int y, int width) {

	} 
	 public void insert(Object object, int index) 
	 {
	        _listElements.insertElementAt(object, index);
	 }
	 
	 public void erase() 
	 {
	        _listElements.removeAllElements();
	 }
	  protected boolean touchEvent(TouchEvent message)
	     {
	     	 int x = message.getX( 1 );
	          int y = message.getY( 1 );
	          
	          if (message.getEvent() == TouchEvent.CLICK)
	          {
	        	  if(!(btn1.isFocus()||btn2.isFocus()||btn3.isFocus()||btn4.isFocus()||btn5.isFocus()||btn6.isFocus()))
	        	  {
	           	 if (!colourList.isFocus())
	          		{
	              	itemSelected(colourList.getSelectedIndex());
	              	return true;
	          		}
	                else {return false;}
	           	 }else {return false;}
	          } else {return false;}
	          
	     }
	          
	  public boolean navigationClick(int status, int time) {
		     if ((status & KeypadListener.STATUS_TRACKWHEEL) == KeypadListener.STATUS_TRACKWHEEL) {
		       //Dialog.alert("its working");
		     } else if ((status & KeypadListener.STATUS_FOUR_WAY) == KeypadListener.STATUS_FOUR_WAY) {
		      itemSelected(colourList.getSelectedIndex());
		     }
		     return super.navigationClick(status, time);
		  }
	  public void setbtnfocus()
		{
			btn2.setFocus();
		}

	     private void itemSelected(int listIndex)
	     {
	    	 temp = listIndex;
	    	bgthread nbg = new bgthread();
	    	nbg.start();
				
				
	     }
	 public void validate()
	 {
		?? final progressscreen prgs = new progressscreen(); ??UiApplication.getUiApplication().invokeLater( new Runnable() { public void run () { UiApplication.getUiApplication().pushScreen(prgs);?? }?? } );??
		 String[] ReturnType = new String[]{"Value","String"};
    	 String SOAP_ACTION= "xyz";  
         String METHOD_NAME = "xyz";    
         String NAMESPACE = "xyz";  
         String URL= "xyz";
     	 String xmldata= "<xml data/>";
			MyAddressParser NewAddress = new MyAddressParser();
			try{	
		NewAddress.validatesax(SOAP_ACTION,METHOD_NAME,NAMESPACE,URL,xmldata,ReturnType);
		ParentId = valuesettertrc.getTypeArraylist().elementAt(temp).toString();
		ServiceName = valuesettertrc.getTypedescarr().elementAt(temp).toString();
	 ??UiApplication.getUiApplication().invokeLater( new Runnable() ?? { ?? public void run () ?? {
	        	 UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen());??
		UiApplication.getUiApplication().pushScreen(new ServiceProvider());
	         } } );}??
			catch (Exception e)
			{
				
			}
	 }
	
class bgthread extends Thread{
		
		bgthread(){
			
		}
		public void run()
		{
			
			validate();
		}
}
}

 

The next code is the one where it is giving me the error on inserting the same lines of code as in the above class:-

 

I have bold and underlined the code fo reasy understanding better.

 

package com.address.active;

import java.util.Vector;

import com.address.bussinesslogic.MyAddressParser;
import com.address.bussinesslogic.ReadCode;
import com.address.bussinesslogic.SaxHandlerBDI;
import com.address.bussinesslogic.SaxHandlerRC;
import com.address.bussinesslogic.SaxHandlerRSp;
import com.address.bussinesslogic.TransactionStatus;
import com.address.bussinesslogic.ValueSetterBDI;
import com.address.bussinesslogic.ValueSetterRC;

import net.rim.device.api.system.Bitmap;
import net.rim.device.api.system.Display;
import net.rim.device.api.system.KeypadListener;
import net.rim.device.api.ui.DrawStyle;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.TouchEvent;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.BitmapField;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.ListField;
import net.rim.device.api.ui.component.ListFieldCallback;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;

public class ServiceProvider extends MainScreen implements ListFieldCallback,FieldChangeListener {
	
	private BitmapButtonField btn1,btn2,btn3,btn4,btn5,btn6;
	private Vector _listElements;
    private ColouredListField colourList;
	ValueSetterRC valuesetterrc;
	ValueSetterBDI valuesetterbdi;
	public static String ServiceProviderName=null,ProviderMasterID=null;
	Font myFont =null;
	MyTooltip _tooltip;
	int temp1;
	public ServiceProvider()
	{
		super(NO_VERTICAL_SCROLL);
		if(Display.getWidth()>360)
		{
		myFont = Font.getDefault().derive(Font.PLAIN, 16);
	   
		}
		else
		{
			myFont = Font.getDefault().derive(Font.PLAIN, 12);
	    
		}
		int spacing=(Display.getWidth()-230)/6;
		
		LabelFieldWhite label=new LabelFieldWhite("Service Provider");
		int mar=(30-label.getPreferredHeight())/2;
		label.setMargin(mar, 0, mar, 5);
		
		LabelFieldWhite label1=new LabelFieldWhite("My Address");
		label1.setMargin(mar, 5, mar, 0);	
		
		BitmapField bitmap=new BitmapField(Bitmap.getBitmapResource("logo.png"));
		int mar2=(30-bitmap.getPreferredHeight())/2;
		bitmap.setMargin(mar2, 5, mar2, Display.getWidth()-15-label.getPreferredWidth()-label1.getPreferredWidth()-bitmap.getPreferredWidth());
					
		HorizontalField header=new HorizontalField("br1.png",Display.getWidth(),30);
		header.add(label);
		header.add(bitmap);
		header.add(label1);
		
		this.add(header);
		
		btn1 = new BitmapButtonField(Bitmap.getBitmapResource("icon1.png"),Bitmap.getBitmapResource("icon1H.png"),"",4);
	    HorizontalField hori=new HorizontalField("tab bar.png",Display.getWidth(),btn1.getPreferredHeight()+20);
	    btn1.setMargin(10, spacing, 10, spacing);
	    btn1.setChangeListener(this);
	    hori.add(btn1); 
	    
	    btn2 = new BitmapButtonField(Bitmap.getBitmapResource("icon2.png"),Bitmap.getBitmapResource("icon2H.png"),"",4);
	    btn2.setMargin(10, 0, 10, spacing);
	    btn2.setChangeListener(this);
	    hori.add(btn2);
	    
	    btn3 = new BitmapButtonField(Bitmap.getBitmapResource("icon3.png"),Bitmap.getBitmapResource("icon3H.png"),"",4);

	    btn3.setMargin(10, 0, 10, spacing);
	    btn3.setChangeListener(this);
	    hori.add(btn3);
	    
	    btn4 = new BitmapButtonField(Bitmap.getBitmapResource("icon4.png"),Bitmap.getBitmapResource("icon4H.png"),"",4);
	    btn4.setMargin(10, 0, 10, spacing);
	    btn4.setChangeListener(this);
	    hori.add(btn4);
	    
	    btn5 = new BitmapButtonField(Bitmap.getBitmapResource("icon5.png"),Bitmap.getBitmapResource("icon5H.png"),"",4);
	    btn5.setMargin(10, 0, 10, spacing);
	    btn5.setChangeListener(this);
	    hori.add(btn5);
	    
	    btn6 = new BitmapButtonField(Bitmap.getBitmapResource("icon6.png"),Bitmap.getBitmapResource("icon6H.png"),"",4);


	    btn6.setMargin(10, 0, 10, spacing);
	    btn6.setChangeListener(this);
	    hori.add(btn6);
	    
	    this.add(hori);
	    
	    
	    valuesetterrc = SaxHandlerRSp.sitesListsecond2;
	    Vector array = valuesetterrc.getTypedescarr();
		_listElements  = new Vector(array.size(), 1);
        colourList = new ColouredListField(false);
        colourList.setRowHeight(44);
		colourList.setCallback(this);
		   

		    for(int count = 0; count<array.size(); count++)
		    {
		    
		       colourList.insert(count);
		       this.insert(array.elementAt(count), count);
		    }

		    LabelField la=new LabelField("Lorem ipsum dolor sit amit, et anim quis nostored",LabelField.USE_ALL_WIDTH | DrawStyle.HCENTER);
		    la.setFont(myFont);
		    la.setMargin(30, 20, 30, 20);
		    colourList.setMargin(0, 0, 0, 0);
		    
		    this.add(la);
		    VerticalFieldManagersecondary = new VerticalFieldManager(VERTICAL_SCROLL);
		    secondary.add(colourList);
		    this.add(secondary);
		    setbtnfocus();
	}
	
	public Object get(ListField list, int index) 
	{
		 return _listElements.elementAt(index);
	} 
	public int indexOfList(ListField list, String p, int s) 
	{ 
	    return _listElements.indexOf(p, s); 
	} 
	public int getPreferredWidth(ListField list) 
	{ 
	    return Display.getWidth(); 
	}
	public void drawListRow(ListField listField, Graphics graphics,
		int index, int y, int width) {

	} 
	 public void insert(Object object, int index) 
	 {
	        _listElements.insertElementAt(object, index);
	 }
	 
	 public void erase() 
	 {
	        _listElements.removeAllElements();
	 }
	 protected boolean touchEvent(TouchEvent message)
	 {
     	 int x = message.getX( 1 );
          int y = message.getY( 1 );
          
          if (message.getEvent() == TouchEvent.CLICK)
          {
        	  if(!(btn1.isFocus()||btn2.isFocus()||btn3.isFocus()||btn4.isFocus()||btn5.isFocus()||btn6.isFocus()))
        	  {
           	 if (!colourList.isFocus())
          		{
              	itemSelected(colourList.getSelectedIndex());
              	return true;
          		}
                else {return false;}
           	 }else {return false;}
          } else {return false;}
          
     }
	          
	  public boolean navigationClick(int status, int time) {
		     if ((status & KeypadListener.STATUS_TRACKWHEEL) == KeypadListener.STATUS_TRACKWHEEL) {
		       //Dialog.alert("its working");
		     } else if ((status & KeypadListener.STATUS_FOUR_WAY) == KeypadListener.STATUS_FOUR_WAY) {
		      itemSelected(colourList.getSelectedIndex());
		     }
		     return super.navigationClick(status, time);
		  }
	  public void setbtnfocus()
		{
			btn2.setFocus();
		}

	     
	     private void itemSelected(int listIndex)
	     {
	    	 temp1=listIndex;
// UiApplication.getUiApplication().invokeLater(new Runnable() { // // public void run() { // UiApplication.getUiApplication().pushScreen(new progressscreen()); // // } // });
	    	 String[] ReturnType = new String[1];
				String SOAP_ACTION= "xyz";  
		        String METHOD_NAME = "xyz";    
		        String NAMESPACE = "xyz";  
		        String URL= "xyz";
		        String Xmldata= <xmldata>;
		        MyAddressParser newaddress = new MyAddressParser();
		        try {
					newaddress.validatesax(SOAP_ACTION, METHOD_NAME, NAMESPACE, URL, Xmldata, ReturnType);
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				valuesetterrc = SaxHandlerRSp.sitesListsecond2;
				ProviderMasterID = valuesetterrc.getTypeArraylist().elementAt(listIndex).toString();
				ServiceProviderName = valuesetterrc.getTypedescarr().elementAt(listIndex).toString();
// UiApplication.getUiApplication().invokeLater(new Runnable() { // // public void run() { // 					UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen());
				UiApplication.getUiApplication().pushScreen(new ServiceProvider2(temp1));
// } // 				});

	     }
	
	


}

 

I tried using the same approach as the above class and also tried to put the invokelater directly as above but it gives me error at complie time.

 

even when both codes are similar it is compling and running in one class but it is not at all compiling in the other class. Where as when i coment the invokelater codes in the second class it starts runing fine .

 

I am going in circles and trying to find solution for this, since 1 and a half weeks but no use 

 

I know my coding standards are not good but please do have look into it.

Please guys help me out .

 

Thanks in advance 

Krishnan 

Please use plain text.
Developer
ankityadav4u
Posts: 231
Registered: ‎03-16-2011
My Device: 9700, 9550, and JDE
My Carrier: AIRTEL, BSNL

Re: Error on trying to add new code into my project

make sure u have set PATH variable in system's environment like in this img

 

then restart ur eclipse.............


available on: Monday to Friday, Indian standard (day) time : )
  • Give kudos by clicking on the star icon to say "Thanks!" if you feel this response is helpful.
  • Click "Accept as Solution" if this post was what you needed. so that people who are trying to help will not waste their time reading a thread where no help is needed.

Please use plain text.
Developer
krishnanmurari
Posts: 80
Registered: ‎06-06-2011
My Device: bold 9000
My Carrier: airtel

Re: Error on trying to add new code into my project

Hi Ankit;

 

Thanks for such an early reply.

 

I tried out exactly the way you told and still the error exsists. I tried the same thing first time itself when i got this error.

no use.

 

the error is 

I/O Error: Cannot run program "jar": CreateProcess error=2, The system cannot find the file specifiedPackaging project My Address1 failed (took 3.278 seconds) 

 

i am unable to proceed, due to this error its not working in other screens also.

 

please do let me know anything. cause i am new to Blackberry Development.

 

Thanks

Krishnan

Please use plain text.
Trusted Contributor
hardikhamar
Posts: 159
Registered: ‎02-17-2011
My Device: Not Specified

Re: Error on trying to add new code into my project

please run other simple app and see that same error occur or not.

If same error occur then there is problem of path which u must have to set.

 

Please use plain text.