0

I am working on an embedded platform where I don't have java.net package (and consequently java.net.URI). I try to create an HttpClient using Apache libraries, but when I create an HttpGet object and pass a String parameter like this

String request = "www.example.com";
HttpGet response = new HttpGet(request);

I still get

The type java.net.URI cannot be resolved.

Why can't I just use new HttpGet(String) constructor?

The same conflict happens when I try to create a JSONObject from String and the constructor demands java.util.Map that I don't have either.

Limbo Exile
  • 1,321
  • 2
  • 21
  • 41
  • 1
    Please post some code and compiler error/stacktrace. Do you get this error during compile time or runtime? The error message you get seems to indicate a different problem than the one you mentioned. – Axel Feb 22 '13 at 11:18
  • So, this is a compile time error: `The type java.net.URI cannot be resolved. It is indirectly referenced from required .class files` The code is pretty much those 2 lines I mentioned in the question. – Limbo Exile Feb 22 '13 at 11:20
  • How that? Have you removed the standard Java libraries from the build path? – Axel Feb 22 '13 at 11:23
  • I think I didn't explain well, sorry. I don't have all the standard Java libraries, I work on a platform that uses a subset of Java libraries. So, I cannot import java.net.URI. Because java.net is not in the subset of the platform.. – Limbo Exile Feb 22 '13 at 11:34
  • 1
    You'll have to find alternative libraries that are written for your specific platform. Libraries that were written for Java SE are going to fail sooner or later when they try internally to use a class that your not-Java platform doesn't provide. – Ian Roberts Feb 22 '13 at 11:54
  • this example.com is not valid URI, try other valid url – navyad Feb 22 '13 at 11:58

1 Answers1

0
String request = "www.example.com";
HttpGet response = new HttpGet();
resporse.setURI(new URI(request));
madlymad
  • 6,367
  • 6
  • 37
  • 68