BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 05-19-2010, 05:51 AM   #1 (permalink)
New Member
 
Join Date: May 2010
Model: 9530
PIN: N/A
Carrier: J2ME
Posts: 2
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default JVM Error 104 Uncaught: NoClassDefFoundError

Please Login to Remove!

Hi All,

I have tried all available options in Forums, but still i am facing the same problem while Logging to my application. When i Debug the Application i found that the problem is with the Class Initialization(i.e crating a Class Instance) at that point the Debug Stop and in Simulator it remains the Login Screen itslef.
but if run the Application in Run mode it throws and exception
"JVM Error 104 Uncaught: NoClassDefFoundError"

And let you know that the same code working fine in J2ME default Simulator.

I have been struck here for last 3 days, Please Help me out in solving this Issue.

Thank You in Advance,
Regards
Vinay
Offline  
Old 05-19-2010, 01:22 PM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

This is probably a JDE level/OS level mismatch issue.

For example, if you compile on 5.0, but run the code on 4.5, you will get something like this.

The JDE level must be less than or equal to the target OS.
Offline  
Old 07-06-2010, 08:13 AM   #3 (permalink)
New Member
 
Join Date: Jul 2010
Model: emul
PIN: N/A
Carrier: None
Posts: 1
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm also tearing my hair out trying to find the problem. I'm using the standard Blackberry JRE 5.0.0 and using default java compliance compiler settings. It happens when I add the following class:

import java.util.Vector;

import javax.microedition.pim.Contact;
import javax.microedition.pim.PIM;
import javax.microedition.pim.PIMException;
import javax.microedition.pim.PIMItem;

import net.rim.blackberry.api.pdap.BlackBerryContact;
import net.rim.blackberry.api.pdap.BlackBerryContactList;
import net.rim.device.api.math.Vector3f;
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.system.Display;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.DrawStyle;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.MenuItem;
import net.rim.device.api.ui.component.ListField;
import net.rim.device.api.ui.component.ListFieldCallback;



/** custom listmodel that sync's and auto-binds with the listfield */
class MyListModel implements ListFieldCallback {

private Vector _data = new Vector();
private ListField _view;
private int _defaultRowHeight = 32;
private int _defaultRowWidth = _defaultRowHeight;
private int _textImagePadding = 5;
private Bitmap _bitmap;

/** constructor that saves a ref to the model's view - {@link ListField}, and binds this model to the view */
public MyListModel(ListField list) {
// save a ref to the list view
_view = list;

// bind this model to the given view
list.setCallback(this);

// set the default row height
_view.setRowHeight(_defaultRowHeight);

// load the bitmap to use in the cell rendering
_bitmap = null;// load some bitmap of your choice here
}

//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXX
// implement ListFieldCallback interface
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXX

/** list row renderer */
public void drawListRow(ListField list, Graphics g, int index, int y, int w) {

String text = (String) _data.elementAt(index);
g.setColor(Color.WHITE);
// draw the text /w ellipsis if it's too long...
g.drawText(text,
_defaultRowWidth + _textImagePadding, y,
DrawStyle.LEADING | DrawStyle.ELLIPSIS,
w - _defaultRowWidth - _textImagePadding);


// draw the to the left of the text...
//g.drawBitmap(0, y, _bitmap.getWidth(), _bitmap.getHeight(), _bitmap, 0, 0);

}

/** list row data accessor */
public Object get(ListField list, int index) {
return _data.elementAt(index);
}

/** used for filtering list elements */
public int indexOfList(ListField list, String p, int s) {
return _data.indexOf(p, s);
}

/** used for rendering list... provide the width of the list in pixels */
public int getPreferredWidth(ListField list) {
return Display.getWidth();
}

//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXX
// data manipulation methods... not part of the interface
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXX

/** mutator, which syncs model and view */
public void insert(String toInsert, int index) {
// update the model
_data.addElement(toInsert);

// update the view
_view.insert(index);
}
/** mutator, which syncs model and view */
public void delete(int index) {
// update the model
_data.removeElementAt(index);

// update the view
_view.delete(index);
}
/** mutator, which syncs model and view */
public void erase() {
int size = _data.size();

// update the view
for (int i = 0; i < size; i++) {
delete(size - i - 1);
}
}
public void modify(String newValue, int index) {
// update the model
_data.removeElementAt(index);
_data.insertElementAt(newValue, index);

// update the view
_view.invalidate(index);
}
public int size() {
return _data.size();
}

//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXX
// get sample actions
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXX

public ActionListenerIF getAddAction() {
return new ActionListenerIF() {
public void actionPerformed(Object source) {
// add a row to the bottom
int size = size();

PIM pim = PIM.getInstance();
BlackBerryContactList list =null;
try {
list = (BlackBerryContactList)
PIM.getInstance().openPIMList(PIM.CONTACT_LIST, PIM.READ_WRITE);
} catch (PIMException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

PIMItem item = list.choose();
BlackBerryContact contact = null;
if (item instanceof BlackBerryContact)
{
contact = (BlackBerryContact) item;
int values = contact.countValues(BlackBerryContact.TEL);
String number = contact.getString(BlackBerryContact.TEL, 0);
System.out.println("Number is: " + number);
//System.out.println("Name is: " + contact.getString(BlackBerryContact.NAME_FAMILY_YO MI,0));
}
//contact.getString(BlackBerryContact.NAME_GIVEN_YOM I,0)+
insert(getDisplayName(contact)+" "+contact.getString(BlackBerryContact.TEL, 0),size);
}
};
}

private String getDisplayName(Contact contact) {
if (contact == null) {
return null; }

String displayName = null;

// First, see if there is a meaningful name set for the contact.
if (contact.countValues(Contact.NAME) > 0) {
final String[] name = contact.getStringArray(Contact.NAME, 0);
final String firstName = name[Contact.NAME_GIVEN];
final String lastName = name[Contact.NAME_FAMILY];
if (firstName != null && lastName != null) {
displayName = firstName + " " + lastName;
} else if (firstName != null) {
displayName = firstName;
} else if (lastName != null) {
displayName = lastName;
}

if (displayName != null) {
final String namePrefix = name[Contact.NAME_PREFIX];
if (namePrefix != null) {
displayName = namePrefix + " " + displayName;
}
return displayName;
}
}

// If not, use the company name.
if (contact.countValues(Contact.ORG) > 0) {
final String companyName = contact.getString(Contact.ORG, 0);
if (companyName != null) {
return companyName;
}
}
return displayName;
}


public ActionListenerIF getRemoveAction() {
return new ActionListenerIF() {
public void actionPerformed(Object source) {
// remove from the top
if (size() > 0) {
delete(0);
}
}
};
}

public ActionListenerIF getEraseAction() {
return new ActionListenerIF() {
public void actionPerformed(Object source) {
// remove all
erase();
}
};
}

public ActionListenerIF getModifyAction() {
return new ActionListenerIF() {
public void actionPerformed(Object source) {
// remove all
modify("new value", size() - 1);
}
};
}

//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXX
// get sample menuitems
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXX

public MenuItem getAddMenuItem(int ordinal, int priority) {
return new MenuItem("Add", ordinal, priority) {
public void run() {
getAddAction().actionPerformed(_view);
}
};
}

public MenuItem getRemoveMenuItem(int ordinal, int priority) {
return new MenuItem("Remove", ordinal, priority) {
public void run() {
getRemoveAction().actionPerformed(_view);
}
};
}
public MenuItem getModifyMenuItem(int oridinal, int priority) {
return new MenuItem("Modify", oridinal, priority) {
public void run() {
getModifyAction().actionPerformed(_view);
}
};
}
public MenuItem getEraseMenuItem(int ordinal, int priority) {
return new MenuItem("Erase", ordinal, priority) {
public void run() {
getEraseAction().actionPerformed(_view);
}
};
}
}// end class MyListModel

and this class:

import net.rim.device.api.ui.ContextMenu;
import net.rim.device.api.ui.MenuItem;
import net.rim.device.api.ui.component.ListField;
import net.rim.device.api.ui.component.Menu;


public class MyListField extends ListField {
private Menu _contextMenu = new Menu();

public void addToContextMenu(MenuItem menuitem) {
if (menuitem != null) _contextMenu.add(menuitem);
}

public ContextMenu getContextMenu() {
// DO NOT call ContextMenu.getInstance()... this will produce null in many cases!!!

ContextMenu cMenu = super.getContextMenu();

cMenu.clear();

int size = _contextMenu.getSize();

for (int i = 0; i < size; i++) {
cMenu.addItem(_contextMenu.getItem(i));
}

return cMenu;
}

}//end class MyListField



Also, I have some previous blackberry projects which keep installing on the emulator even though they've been deleted from the workspace and reappear everytime I launch. How do I delete them permanently?!

Last edited by smackyb : 07-06-2010 at 08:17 AM.
Offline  
Old 07-06-2010, 11:28 AM   #4 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

What class is it coimplaining about? Where is the stack trace?

Please do some basic problem determination here...
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.