1

I am trying to send a single ping test to Flickr using flickrj. I am following step by step the tutorial here

https://github.com/callmeal/Flickr4Java

imported all the maven dependencies and everything and ended up with the following code:

import java.util.Collections;

import com.flickr4java.flickr.Flickr;
import com.flickr4java.flickr.REST;
import com.flickr4java.flickr.collections.Collection;

import com.flickr4java.flickr.test.TestInterface;

public class hello {
    public static void main(String args[]){


    String apiKey = "3f7046fe0897516df587cc3e6226f878";
    String sharedSecret = "9d0ceef5f2f3040f";
    Flickr f = new Flickr(apiKey, sharedSecret, new REST());
    TestInterface testInterface = f.getTestInterface();
    Collection results = testInterface.echo(Collections.EMPTY_MAP);

    }
}

I get the following error though:

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
    Type mismatch: cannot convert from Collection<Element> to Collection

    at hello.main(hello.java:18)

What am I doing wrong?

  • Did you try Collection results = testInterface.echo(Collections.EMPTY_MAP);? – Zaid Malhis Aug 11 '15 at 08:34
  • @ZaidMalhis yes i forgot to mention that I had tried that and i got the following: The type Collection is not generic; it cannot be parameterized with arguments – Bombastrelopas Aug 11 '15 at 08:42

2 Answers2

0

As per the documentation here, you would need a cast to

Collection<Element> results = testInterface.echo(Collections.EMPTY_MAP);

The signature is..

public Collection<Element> echo(Map<String, String> params) throws  FlickrException {
....
    return response.getPayloadCollection();
}
  • I have tried casting but then I get the following error: Exception in thread "main" java.lang.Error: Unresolved compilation problem: The type Collection is not generic; it cannot be parameterized with arguments at hello.main(hello.java:18) I also tried copy pasting the documentation code itself you gave and i get the same error even with that. – Bombastrelopas Aug 11 '15 at 08:52
  • Some answers [here](http://solvedstack.com/questions/the-type-collection-is-not-generic-it-cannot-be-parameterized-with-arguments-extends-e) for that... you might also want to try what Zaid suggested below – ThreeSidedCoin Aug 11 '15 at 09:00
0

You might have a conflict in imports, you are using com.flickr4java.flickr.collections.Collection while you most probably - as the echo method return type states - want to use java.util.Collection Class. replace the line with:

java.util.Collection<Element> results = testInterface.echo(Collections.EMPTY_MAP);

Your Code:

import java.util.Collections;

import com.flickr4java.flickr.Flickr;
import com.flickr4java.flickr.REST;
import com.flickr4java.flickr.collections.Collection;

import com.flickr4java.flickr.test.TestInterface;

public class hello {
    public static void main(String args[]){


    String apiKey = "3f7046fe0897516df587cc3e6226f878";
    String sharedSecret = "9d0ceef5f2f3040f";
    Flickr f = new Flickr(apiKey, sharedSecret, new REST());
    TestInterface testInterface = f.getTestInterface();
    java.util.Collection<Element> results = testInterface.echo(Collections.EMPTY_MAP);

    }
}
Zaid Malhis
  • 588
  • 4
  • 18