• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Interface in a default package

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I declared a new interface (foo)in the default package. When I created a new class in a different package, which implements this foo interface,I got an error message saying foo is not resolved although I did import the interface. However, if I declared the same interface in a proper package(bar) and then import it like this: import bar.foo then it works. why is it? Does anyone know?

Thanks,
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this question is related to eclipse IDE i think, you may post it to IDE's subforum
you can check the folder structure, when you create default package
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please don't post posts that are related to IDE'S...

post them in the respective section,....

thanks
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since one of the newer versions of Java (I think since Java 5) you cannot import classes or interfaces from the default package anymore.

In older versions of Java, it was possible to do that, like this:

import SomeInterface;

But that feature has been removed - you'll get an error message if you try to do this in Java 5 or 6. You must put your interface in a package other than the default pacakge if you want to be able to use it in a different package.
 
wonkty wang
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jesper. It is a lot clearer now.

Btw I wasnt sure this is a IDE specfic issue.
 
Good heavens! What have you done! Here, try to fix it with this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic