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
tklanilkumar
Posts: 206
Registered: ‎02-22-2011
My Device: BB TORCH & 9800
My Carrier: idea

Java Accessibility issue - "class of default package into anyother created package"

[ Edited ]

Hi all,

 

I created a new java project in eclipse it appears src folder by default,

I created a "One.java" class in src without creating any package so it itself created in (default package)

Now I created "Two.java" class in "com.test" package.
Now my question is I want to access the method of class "One.java" in "Two.java".

After searching I have done it through Reflection (in run time) .

 

I need for some other solution/ approach other than reflection mechanism.

 

Thanks in Advance

Anil Kumar R

 

 

 

 

 

 

*****************************************************************************
* Give kudos when you like it
* Mark it as a solution if it fixes your issue
Please use plain text.
Developer
simon_hain
Posts: 16,113
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Java Accessibility issue - "class of default package into anyother created package"

classes in the default package are not visible for classes outside of it, this is by design.
simple solution: don't use the default package
----------------------------------------------------------
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
Please use plain text.
Developer
tklanilkumar
Posts: 206
Registered: ‎02-22-2011
My Device: BB TORCH & 9800
My Carrier: idea

Re: Java Accessibility issue - "class of default package into anyother created package"

[ Edited ]

Hi simon,

The classes and package structure is like that only its made (all classes bundled as jar file),
I have to get and use the class(s) from default package to other package.

In this scenario how can I achieve.

*****************************************************************************
* Give kudos when you like it
* Mark it as a solution if it fixes your issue
Please use plain text.
Developer
simon_hain
Posts: 16,113
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Java Accessibility issue - "class of default package into anyother created package"

i am not 100% sure how it is handled in j2me, i only know that from desktop java, look it up, for example
http://stackoverflow.com/questions/283816/how-to-access-java-classes-in-the-default-package
----------------------------------------------------------
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
Please use plain text.
Developer
tklanilkumar
Posts: 206
Registered: ‎02-22-2011
My Device: BB TORCH & 9800
My Carrier: idea

Re: Java Accessibility issue - "class of default package into anyother created package"

Yes simon, I got to know inorder to achieve it by Reflection mechanism as you also suggested url above.

The scenario now im having is

In default package I have 3 classes
One abstract parent class and two subclasses

Q.1 , I have to invoke the method of abstract class (which is in default package) from other package of any class,

Q.2 , I have to access the overriden methods of subclasees (which are in default package) from other package of any class.
.

Note: I achieved to call the methods of subclasses with Reflection mechanism i.e., with Class.forName("particular class name") etc.,

Thanks in advance
*****************************************************************************
* Give kudos when you like it
* Mark it as a solution if it fixes your issue
Please use plain text.