• Post Reply Bookmark Topic Watch Topic
  • New Topic

Seems impossible , please help me......  RSS feed

 
Srinivas Kalvala
Ranch Hand
Posts: 257
Firefox Browser Hibernate Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My requirement is ,

Assume I have three Packages A, B, C and these three are in single Jar file.

I want to Make the Package C visible to Outside but Only C Should access the Packages A,B.

No one should be allowed to access the Packages A,B but C.

Waiting for reply..............
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java doesn't work that way, sorry. A class is either public (visible outside its package) or not.
 
Yuriy Zilbergleyt
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only thing even slightly close (though not really) could be achieved using the protected modifier. If all classes in A and B are protected, and classes in C extend those.... But then again, nothing would stop classes from packaged D from extending classes from packages A and B as well.

Yuriy
 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well can packages be defined as public?

cause if so..

just have package c public..

and packages a and b extend package c

if you can do that...

but if the classes variables and methods inside package c are private,

then only those methods can access right?..

But, I feel as if im getting packages and classes confused..

if someone could...help me out here.

-Justin-

I dont know lol
 
Jass Singh
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Justin Fox:
well can packages be defined as public?

cause if so..

just have package c public..



We can't specify access modifiers with package declaration.



and packages a and b extend package c


Also a package can't extend another package. Only a Class or Interface can do that

Regards,
Jass
 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thx for clarifying that for me

-Justin-
 
Srinivas Kalvala
Ranch Hand
Posts: 257
Firefox Browser Hibernate Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is it possible if we use any Design Patterns like...
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by j rangavallika:
is it possible if we use any Design Patterns like...


like what?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!