I am using Eclipse IDE for Enterprise java and web developers. I downloaded some zip file called facts(1) and followed every step in setting up this facts project. When I try to run it on server it showing " ... doesn't match the expected package. I tried by adding import package facts; and also without that! I have also looked similar answer and didn't able to fix that either. FYI i have jdk (16.0.2) currently.
[enter image descripenter image description heretion here]2
CodePudding user response:
you classes Fact.java
, FactList.java
, FactSearchModel.java
and few more are in default package
create a package and move these classes to package, then import that package wherever required
CodePudding user response:
As you are using default package for your facts classes like Fact.java, FactList.java, you do not need to import it. However, I think your fact files Fact.java, FactList.java, etc are also failing compilation as the package declaration on those files are not same as the folder structure.
So please try these:
Make sure that there is no statement
package xxx.yyy.zzz;
in your fact classes Fact.java, FactList.java, etc and they are compiling successfully i.e. no errors in those files.
- Remove the import statement in FactServlet.java as it is not required.
But.. according to Java standards using default package is not advisable. Create proper directory structure for your files.