BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 08-30-2007, 10:23 AM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Jul 2007
Model: 8800
PIN: N/A
Carrier: t-mobile
Posts: 44
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default class multiply defined

Please Login to Remove!

I will try to specify my problem short and precise.

I run a background-thread which fetches data and stores it persistently.
To store the data, a persistent class Name is used.
I have an AddressBook (the GUI application) which retrieves the persistent data with getContent(). The getContent() method returns an Object so it has to be casted to Name.
Name test = (Name) persistentStorage.getContent();
Now i have included the Name.java file in the AddressBooks ant-build. This works fine (it compiles).
The effect is, that the background thread is running without a problem BUT when i try to start the gui-application (AddressBook) i get the error message:
Error starting AddressBook: Class 'BackgroundThread.Name' multiply defined.

When i searched the forum, i saw that a few people encountered similiar problems, so i hope that somebody is able to help me on that.

Last edited by tschiefer : 08-30-2007 at 10:26 AM.
Offline  
Old 08-30-2007, 11:21 AM   #2 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Posts: 259
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've seen this in the context of when I deployed an application to the device. Then deleted it, but didn't reboot, then re-installed it, the jvm held two instances of the classes inside. if you wipe and reboot you might be fine, could be other things too I suppose.
Offline  
Old 08-30-2007, 11:27 AM   #3 (permalink)
Knows Where the Search Button Is
 
Join Date: Jul 2007
Model: 8800
PIN: N/A
Carrier: t-mobile
Posts: 44
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thx for your reply - i have encoutered the problem you described and solved it by executing the clean.bat file.
But unfortunatly this error occurs because of some other reason, which is still not clear to me.
Offline  
Old 08-30-2007, 01:19 PM   #4 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Posts: 259
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok, lets see, is the persistent Name class nested w/i your BackgroundThread Class? Also, are these two different packages entirely? That is, you have a BackgroundThread deployed as well as another package for your UIApplication? if you don't have that class nested w/i background thread and you define Name in both packages, you'll see a namespace collision in the jvm
Offline  
Old 08-31-2007, 02:16 AM   #5 (permalink)
Knows Where the Search Button Is
 
Join Date: Jul 2007
Model: 8800
PIN: N/A
Carrier: t-mobile
Posts: 44
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

i'm using eclipse and the background-thread and the gui-application are two different projects. so yes, the two applications are split up into two different packages.
The persistent class Name exist within com.company.backgroundThread.src
and i imported it in the needed classes within com.company.GuiApplication.src.

I thought about making a library for the persistent class Name and then import the library into the two applications. Do you think, that makes sense?
Offline  
Old 08-31-2007, 10:37 AM   #6 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Posts: 259
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

That would probably work, it sounds like you're probably defining it in two different packages causing the collision. See if that works
Offline  
Old 09-03-2007, 10:11 AM   #7 (permalink)
Knows Where the Search Button Is
 
Join Date: Jul 2007
Model: 8800
PIN: N/A
Carrier: t-mobile
Posts: 44
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

The solution with the library works fine. I have now defined the classes which are used from both applications (background thread and gui app) only once: in a separate library. And then set the project depencies from both projects to that library.

Problem is, that i now have to work with the RIM IDE (instead eclipse), which i don't like at all.
If somebdy knows how to configure the rapc-tasks in the ant file for building a library and including it into other projects, i would appreciate some advice.
Offline  
Old 09-04-2007, 05:17 PM   #8 (permalink)
Talking BlackBerry Encyclopedia
 
Skipper_Joe's Avatar
 
Join Date: Jan 2007
Location: Kharkov, Ukraine
Model: 8300
Carrier: N/A
Posts: 237
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

it is possible to run command-line compiler rapc.exe from JDE using ant task <exec>.

About rapc.exe see: Livelink - Redirection

also there is chapter "Using the command line" in BlackBerry Application Developer Guide, Volume 1
Offline  
Old 09-05-2007, 11:38 AM   #9 (permalink)
Knows Where the Search Button Is
 
Join Date: Jul 2007
Model: 8800
PIN: N/A
Carrier: t-mobile
Posts: 44
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

thank you for your help, but in a project which contains more than a few classes, it is laborious to use the command line, so i finally got the ant file working the way i wanted.

rapc task for library
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.