# Import java.net.URI doesn't work

**URL:** https://discourse.processing.org/t/import-java-net-uri-doesnt-work/13425
**Category:** Beginners
**Created:** [August 17, 2019, 9:18am UTC](https://discourse.processing.org/t/import-java-net-uri-doesnt-work/13425 "2019-08-17T09:18:28Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![devlogerio](https://avatars.discourse-cdn.com/v4/letter/d/ec9cab/32.png) [@devlogerio](https://discourse.processing.org/u/devlogerio)
#### Post date: [August 17, 2019, 9:18am UTC](https://discourse.processing.org/t/import-java-net-uri-doesnt-work/13425/1 "2019-08-17T09:18:28Z")

</div>

I am going to make a URI using java.net.URI, it gives me the following error Unhandled exception type URISyntaxException, Im wondering why (import java.net.URI) is not working!

Can anyone suggest anything?

> Error: Unhandled exception type URISyntaxException

Code:

```auto
import java.net.URI;
import java.net.URISyntaxException;

URI uri = new URI("ws://asdasdsad:2000");

```

---

<div class="post-metadata">

### Author: ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)
#### Post date: [August 17, 2019, 10:00am UTC](https://discourse.processing.org/t/import-java-net-uri-doesnt-work/13425/2 "2019-08-17T10:00:23Z")

</div>

see here [https://examples.javacodegeeks.com/core-java/net/urisyntaxexception/java-net-urisyntaxexception-how-to-solve-urisyntaxexception/](https://examples.javacodegeeks.com/core-java/net/urisyntaxexception/java-net-urisyntaxexception-how-to-solve-urisyntaxexception/) , possibly better way.

i try

```auto
import java.net.URI;
import java.net.URISyntaxException;

URI uri;// = new URI("ws://asdasdsad:2000");

void setup() {
  try {
// uri = new URI("http://www.javacodegeeks.com/");
    uri = new URI("ws://asdasdsad:2000");
    println("URI parsed succesfully!");
  } 
  catch (URISyntaxException e) {
    e.printStackTrace();
  }
}

```

looks good, but i not know what it is about,  
but you also did not elaborate what you want to do …

---

<div class="post-metadata">

### Author: ![neilcsmith](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/neilcsmith/32/144_2.png) [@neilcsmith](https://discourse.processing.org/u/neilcsmith)
#### Post date: [August 17, 2019, 10:41am UTC](https://discourse.processing.org/t/import-java-net-uri-doesnt-work/13425/3 "2019-08-17T10:41:24Z")

</div>

@devlogerio if you know the URI is valid (not user input), use [URI::create](https://docs.oracle.com/javase/8/docs/api/java/net/URI.html#create-java.lang.String-) instead.

eg.

```auto
uri = URI.create("ws://asdasdsad:2000");

```
