BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 04-04-2008, 11:50 AM   #1
lionscribe
Knows Where the Search Button Is
 
Join Date: Feb 2008
Model: none
Carrier: sprint
Posts: 24
Post Problem class not found (Update to thread)

Please Login to Remove!

Unfortunately the thread "Problem class not found" got lost during the recent Server Meltdown, and thread itself is not found )
But since I came up with a solution, I will state the original problem, and follow that with a solution.

Problem: When the developer wants to add an optional class to his project that is only available in let's say BB version 4.2, but he wants his application to work on 4.1, so the assumed solution would be to put the call to that class in a try-catch, and compile it in JDE 4.2

For example if the developer wants to add the Blackberry Map Class to his project, which is only available in 4.2, he may want to do the following

try
{
MapsArguments args = new MapsArguments((Contact)contact ,0);
Invoke.invokeApplication( Invoke.APP_TYPE_MAPS, args);
}
catch (ClassNotFoundException e)
{
Dialog.notify("Your Device does not support this option");
}

The problem is that this does NOT work, because when you launch the application, JVM throws a ClassNotFoundException before the application runs, and you have no chance to catch it.

This was the original problem posted by someone, and there were quite a few replies, but with no solution. I will post a solution in the next Post.

Lionscribe
Offline  
Old 04-04-2008, 12:04 PM   #2
lionscribe
Knows Where the Search Button Is
 
Join Date: Feb 2008
Model: none
Carrier: sprint
Posts: 24
Smile

Well now for the solution.
I created a seperate projects. I called it MapInvoke, set it up as a Library, and it has one single class, which extends (believe it or not) the Vector class. The reason for extending is so that we can easily use the Base class in another project and call the overridden base methods, without declaring the class in the other project. And here is the code:

public class MapInvoke extends java.util.Vector
{
public MapInvoke()
{
}
public void setElementAt(Object contact, int addressIndex)
{
MapsArguments args = new MapsArguments((Contact)contact ,0);
Invoke.invokeApplication( Invoke.APP_TYPE_MAPS, args);
}

}

Now in my Main project when I have to call this Class, I use this code:
try
{
java.util.Vector mapInvoke = (java.util.Vector)cmi.newInstance();
mapInvoke.setElementAt(contact, 0); // This invokes it
}
catch (Exception e) // usually old model that does not have Maps
{
Dialog,inform("......");
}

Since the new Class is not included in your Main Project (and you cannot include it), you have to use UpdateJad.exe to add the COD file to your project, and you will have to add it manually to your alx file.

I tested this method, and it works.

Good Luck,
Lionscribe
Offline  
Closed Thread



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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


NOK F-TEC VV23F-SC3 Vacuum Solenoid  picture

NOK F-TEC VV23F-SC3 Vacuum Solenoid

$400.00



Solenoid For Delco 10511209, 10511216, 1115664, 1115701, 1115712; 245-12167 picture

Solenoid For Delco 10511209, 10511216, 1115664, 1115701, 1115712; 245-12167

$63.28



VTEC Solenoid Spool Valve Assembly W/Oil Pressure Switch & Gasket Compatible wit picture

VTEC Solenoid Spool Valve Assembly W/Oil Pressure Switch & Gasket Compatible wit

$75.87



Solenoid For Dentsply SPS Cavitron Gen 131 Gen 132 Gen 136 Gen 137 Replacement picture

Solenoid For Dentsply SPS Cavitron Gen 131 Gen 132 Gen 136 Gen 137 Replacement

$146.63



SOLENOID VALVE 1089058012/NON OEM ATLAS COPCO/FREE SHIPPING picture

SOLENOID VALVE 1089058012/NON OEM ATLAS COPCO/FREE SHIPPING

$111.00



Asco 24 V DC 238710-006-D Solenoid Coil 24vdc picture

Asco 24 V DC 238710-006-D Solenoid Coil 24vdc

$76.00







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