• Post Reply Bookmark Topic Watch Topic
  • New Topic

Default package causing compile-time error  RSS feed

 
Vidya Shivram
Ranch Hand
Posts: 38
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I read 
The default package is automatically imported in the java classes and interface defined within the same directory.


Also,
Members of named package can't access classes and interface defined in the default package regardless of whether they are defined in same directory or not.


In the image attached, I see the error in Test2  example file saying the type is already defined. while using the command line as I mention the path I did not find any difficulties there.
isn't Test2 different directory? quote 1 says there are imported only within the same directory.

I am not getting how IDE works or may be I am not understanding how default package works.Please help me with this concept. 



oca-default.PNG
[Thumbnail for oca-default.PNG]
 
Norm Radder
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see the error

Please copy the full text of the error message and paste it here. It has important info about the error.
 
Knute Snortum
Sheriff
Posts: 4289
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe the problem is that you can't have two types with the same name in the same package, regardless of whether they are in separate folders.  That holds for the default package.
 
Norm Radder
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is that just an IDE problem?  I don't use an IDE and have never seen the problem.
 
Knute Snortum
Sheriff
Posts: 4289
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Doesn't look like it's just the IDE:
 
Norm Radder
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>javac test1\example.java test2\example.java

I've never done that (and many other things).  I remember  finding out a lot of different ways to write and compile code when I was a TA.  I guess I found a way that worked and never wandered around any to see if there were other ways to do it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!