Java error: Only a type can be imported. XYZ resolves to a package?

Well, you are not really providing enough details on your webapp but my guess is that you have a JSP with something like that.

Well, you are not really providing enough details on your webapp but my guess is that you have a JSP with something like that: And x.y. Z can't be found on the classpath (i.e. Is not present under WEB-INF/classes nor in a JAR of WEB-INF/lib).

Double check that the WAR you deploy on Tomcat has the following structure: my-webapp |-- META-INF | `-- MANIFEST. MF |-- WEB-INF | |-- classes | | |-- x | | | `-- y | | | `-- Z. Class | | `-- another | | `-- packagename | | `-- AnotherClass.

Class | |-- lib | | |-- ajar. Jar | | |-- bjar. Jar | | `-- zjar.

Jar | `-- web. Xml |-- a. Jsp |-- b.

Jsp `-- index. Jsp Or that the JAR that bundles x.y.Z. Class is present under WEB-INF/lib.

1 +1 you actually took time to construct that ASCII tree?! – anon355079 Dec 7 '09 at 8:08 I used the tree command but I had to customize it a bit :) – Pascal Thivent Dec 7 '09 at 8:10 1 Thanks.It all looks as you say it ought to be, which is why it so confusing. – Ankur Dec 7 '09 at 8:30 Kudos, but package is an illegal package identifier ;) – BalusC Dec 7 '09 at 11:06 @BalusC of course, you're right, but LOL :) – Pascal Thivent Dec 7 '09 at 11:21.

OK I just solved it. In the last import I added a ";" by copying other code examples. I guess it's the standard line ending that is required.So became.

Wow! Thank you, Thank you Thank you! – sixtyfootersdude Apr 20 at 13:33.

Without further details, it sounds like an error in the import declaration of a class. Check, if all import declarations either import all classes from a package or a single class: import all.classes.from.package. *; import only.one.type.named.

MyClass; Edit OK, after the edit, looks like it's a jsp problem. Edit 2 Here is another forum entry, the problem seems to have similarities and the victim solved it by reinstalling eclipse. I'd try that one first - installing a second instance of eclipse with only the most necessary plugins, a new workspace, the project imported into that clean workspace, and hope for the best...

You have to import something FROM the package, like a class, enum, or interfacee, like this: import some.package. SomeClass; or, import everything from the package (not recommended) import some.package. *; edit: maybe I didn't read close enough.

Where is the package you're trying to import from located on the filesystem? Is it under WEB-INF/lib?

Take a look at this link here. They seem to have similar problem in Eclipse. Not sure if you will find the solution there but the last message has some suggestions that you can try out.

Looks like the link is broken. – Phoenix Sep 28 at 19:32.

If so, you can always just use the fully qualified class name. Rather than: import foo.bar. *; Baz myBaz; you can use foo.bar.

Baz myBaz.

I know it's kinda too late to reply to this post but since I don't see any clear answer i'd do it anyway... you might wanna check out the MANIFEST. MF in META-INF on your eclipse. Then you might need to add the path of your class files like.. Class-Path: WEB-INF/classes hope it helps.

:).

I experienced this weird error too, after changing letter case in the name of a class. The file was not copied to a tomcat server as expected, I had to delete it manually and redeploy. Maybe because I use case insensitive operating system?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions