MultipartEntityBuilder.create cannot be resolved to a type

1.6k Views Asked by At

I try to create a multipartEntityBuilder in oder to send an httpRequest. The code i found was using MultipartEntity, so i changed that to MultipartEntityBuilder.
MultipartEntityBuilder reqEntity = new MultipartEntityBuilder.create(); This gives me an error

MultipartEntityBuilder.create cannot be resolved to a type

I have added the httpmime-4.5.jar file in my eclipse /lib (from the properties menu) and i can actually see the create() method inside the MultipartEntityBuilder class.(I cant see the code, just that it exist there).
And of course i have imported it.
import org.apache.http.entity.mime.MultipartEntityBuilder;

I have been looking around and the only answer i could find was to include the jar.
Any ideas?

1

There are 1 best solutions below

0
On BEST ANSWER

If you want to call a method, the expression on the right hand side of the assignment shouldn't start with new:

MultipartEntityBuilder reqEntity = MultipartEntityBuilder.create();

Otherwise the compiler expects a constructor call, which would mean you'd call the default constructor of the create class that is a static inner class of MultipartEntityBuilder.