Win a copy of Head First Android this week in the Android forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Eclipse error : Declared package does not match expected package

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranchers,

I know this is very common error of declaring source folder, but some how I am not able to solve my particular case.

I tried searching through other posts here but could not get to resolve my issue with any of those.

So here is my problem.

I have a project called "javasource" which is created with existing source option. I have 'javasource' folder on my C drive and it has other set of com.mystuff folders etc.

So now javasource/com/mycomp/myfolder/MyClass.java has package declaration statement "package com.mycomp.myfolder;" which gives me error saying declared package does not meet expected package. Aslo, it does not recognize any other classes from that folder ie.. same package. However it recognizes files from other package.

It says expected package is "" so asks me to remove package statement.

My source folder : javasource
output folder : javasource/output

Can someone help me here? How do I get rid of all these errors? I dont want to change any package statements. I am missing something with eclipse build configuration.

Thanks in advance.

- vivian
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you using the Spring Framework or Beans as such..
 
Vivian Josh
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, I am not using any framework. It is basic web application which can not be entirely setup in eclipse. So have to add folders as simple java project.
I can not create web project directly for this one.
 
Seth Anshul
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had this problem as I had not registered the bean.
The issue might be with build paths perhaps..
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you put the cursor inside the erroneous package declaration and press ctrl-1, you should get a list of quick fixes, one of which is "Move 'classname' to package 'packagename'". What happens if you execute it?
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic