Type is known, but method refers to missing type

I'm not very experienced with java and Eclipse and I'm getting the following problem:

I'm writing something like:

Point3D myPoint = myClass.myMethod(arg);

And I got the error:

the method myMethod(myType arg) refers to the missing type Point3D.

However the class Point3D is known, I can create an object of this type (Point3D) without error and I got Point3D methods from auto-completion.

7

5 Answers

You are evidently using a different implementation of Point3D in the class where you have declared the method than where you are calling it.

Go to the declaration of myMethod and check that the import statement for Point3D in that class is the same as the import statement in the class where you are calling myMethod.

2

I got same issue, I solved it by changing the order of import. I put the class which make the issue at the top of import list, after package, then the IDE(VS code) makes no alert.

I had the same problem. It was solved with casting returning value of method to needed class - in your case Point3D

 private static ConcurrentHashMap<Long,HotelInfHQ> HASH_HOTELINF = new ConcurrentHashMap<Long,HotelInfHQ>();
////
public static HotelInfHQ getHotelInfByKey (Long key){ return (HotelInfHQ)HASH_HOTELINF.get(key);
}

and in another class call was like

getHotelInfByKey(value);

Although ConcurrentHashMap HASH_HOTELINF was parametrized and Eclipse didn't show any mistake in return string, it was not obvious to it what class of object it returns at the point of method call

Might depend on your context, but I was having the same issue too until I compiled it. Make sure that Eclipse didn't hide your import statements at the top of your program by minimizing a couple lines. I accidentally imported a file from a previous project of the same name and it hid the import statement at the top: "import A3.BST;". Just expand out to see your lines and delete the import statement and you should be fine.

If you have enabled Java module System without actually configuring it correctly this happens. I decided to remove the Java module system and use only the maven dependencies. In "Java Build Path" ensure that the Classpath dependencies are defined correctly.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like