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: 551
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700
My Carrier: Movistar, Telenor

Maintaing versions

Have now reached the point where more than one level has to be maintained due to differences in the API:s. So I have one for 4.5 and one for 5.0. I have been using Eclipse for 5.0 and Blackberry for 4.5.

So far it has worked with the same source but no longer. It seems that the natural choice is to use Eclipse only and use compiler directives in the source. Eclipse  can have several versions of the API installed. Maybe Blackberry can too, but I have not seen that. Not sure how to best accomplish this.  Is it to switch target  library for generated code and link libraries when switching between the two? How do I make the compiler to understand what version I am compiling?

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Developer
Posts: 16,637
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Maintaing versions

using different libraries is one option. another is called preprocessing, use this as a keyword and you should find numerous posts
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 551
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700
My Carrier: Movistar, Telenor

Re: Maintaing versions

 

simon_hain

 

>use this as a keyword and you should find numerous posts

 

Thats for sure. Does it really help vading thru all these? Got tired after approx 5 of them.People having all kinds of strange problems. So I decided to try documentation.

 

Help in Eclipse

-----------------------------------------

You can specify preprocessor directives for a single project or for all projects in a workspace. You must enable preprocessing in Eclipse® before you can specify preprocessor directives. For more information about how to enable preprocessing, see the BlackBerry Java Plug-in Installation and Configuration Guide.

-----------------------------

Search the web.

Found a Configuration guide:

http://docs.blackberry.com/en/developers/deliverables/12793/Enable_application_preprocessing_655408_...

 

Not bad. Tells me to add   "osgi.framework.extensions=net.rim.ejde"   to the eclipse ini file.  Did that.

 

Next. Specify  for all projects in a workspace. Not mentioned how to do that in this document.

More searching. Found this:

 

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/1407892/How_To_-_Use_...

 

Nice pic showing where to specify the preprocessor statement. The lead says:

BlackBerry Project Properties, Preprocessor defines. Not correct. A bit different on my Eclipse, had to navigate one step further but finally found where to specify the preprocessor define.

 

Still wonder how I specfy it for the complete workspace. Have not found that

 

So. it took me more than one hour to find it. How about a simple "How to" ?

 

So I fix my source code preprocessor statements in the source.

 

And if I understand it correctly I have to do 3 different things before compling when changing between different levels.

 

 - change the preprocessor define

 - change what jre library to use

 - change what output library to place the result in

 

Correct?

 

 

 

 

 

 

 

 

 

 

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Developer
Posts: 16,637
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Maintaing versions

I use preprocessing only in the jde, not in eclipse. in the jde i edit the project file (jdp) and add a line like Options=-quiet -define=PREPROCESSOR;VER_4_7_0_AND_ABOVE the source code file has to start with //preprocess and i can divert my code using //#ifdef VER_4_7_0_AND_ABOVE //#else //#endif
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 551
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700
My Carrier: Movistar, Telenor

Re: Maintaing versions

thanks simon_hain

 

In the documentation I have found nothing is mentioned about adding this statement in the jdp file. Is that a general  requirement  or is it needed only for some specific versions of the jde? What you explain only handles the differences in the source.

 

How do you handle the need for different levels of import libraries and different output libraries?  Or do you use different separate jde installations for the different versions and copy the source code between them?

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Developer
Posts: 16,637
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Maintaing versions

you can detect the platform version in your code and call the correct factory by using class.forName. name the classes with a certain schema, like xxx.4.6 and xxx.4.7 and you can call them by combining your classname and the platform version. i don't use this myself, maybe somebody else can give you more details about it.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 551
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700
My Carrier: Movistar, Telenor

Re: Maintaing versions

Lets hope someone do respond  :-)

 

That implies that I can use the most modern jde but import backlevel libraries.  Hadnt thought of that but its logical. Solves another problem I have. The 4.5 jde do not support "enable device security" on the simulator (or the feature is somewhere else than on 4.7)

 

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-