# Type Serial is ambiguous

**URL:** <https://discourse.processing.org/t/type-serial-is-ambiguous/43584>\
**Category:** Electronics (Arduino, etc.)\
**Created:** [December 30, 2023, 3:06am UTC](https://discourse.processing.org/t/type-serial-is-ambiguous/43584 "2023-12-30T03:06:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rototbob](https://avatars.discourse-cdn.com/v4/letter/r/a8b319/32.png) [@rototbob](https://discourse.processing.org/u/rototbob)\
**Post date:** [December 30, 2023, 3:06am UTC](https://discourse.processing.org/t/type-serial-is-ambiguous/43584/1 "2023-12-30T03:06:54Z")

</div>

I’m new to the Processing language. I am trying to run the code for the Arduino Networked Lamp as detailed in the Getting started with Arduino book. I’ve downloaded the program titled ex06 01 processing and I get the following error when I compile it:

The type Serial is ambiguous  
on line 17:

Serial port;

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [December 30, 2023, 9:08am UTC](https://discourse.processing.org/t/type-serial-is-ambiguous/43584/2 "2023-12-30T09:08:22Z")

</div>

Hi @rototbob,

Please show your imports. The error means, that the Serial class exists more than once in your imported libraries. Best practice is **not** using asterisks on imports, but rather using the explicit imports for your needs.  
If you, for example, use

```auto
import processing.serial.*;
import java.io.*;

Serial serial;

```

It don’t know which Serial to take for Serial, as there are.

`processing.serial.Serial` and `java.io.Serial`

Cheers  
— mnse

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [December 30, 2023, 11:24am UTC](https://discourse.processing.org/t/type-serial-is-ambiguous/43584/3 "2023-12-30T11:24:35Z")

</div>

If you know which Serial you want you can explicitly specify to use then e.g.

```auto
import processing.serial.*;
import java.io.*;

processing.serial.Serial pSerial;
java.io.Serial ioSerial;

// and create them explicitly where ... are the necessary parameters

pSerial = new processing.serial.Serial(...);
ioSerial = new java.io.Serial(...);

```

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [December 30, 2023, 11:41pm UTC](https://discourse.processing.org/t/type-serial-is-ambiguous/43584/4 "2023-12-30T23:41:22Z")

</div>

Hello @rototbob,

The code example works in Processing 3.5.4.  
There is no _java.io.Serial_ in that Java version to create a conflict.

Processing 4.3 uses a newer Java version that now has this:

> **[Uses of Class java.io.Serial (Java SE 14 & JDK 14)](https://download.java.net/java/GA/jdk14/docs/api/java.base/java/io/class-use/Serial.html)**
>
> use: module: java.base, package: java.io, annotation type: Serial

And this adds the ambiguity.

This came up in a search:  
[https://www.reddit.com/r/processing/comments/17c1aqs/type\_serial\_is\_ambiguous/?rdt=57779](https://www.reddit.com/r/processing/comments/17c1aqs/type_serial_is_ambiguous/?rdt=57779)

This also impacted this code and you can see the fix here:

> <https://github.com/OpenBCI/OpenBCI_GUI/commit/2df2612d90c0b2a3ec207342d6df34acf491dc18>
>
> Fixes #1025

If you are doing serial communications to an Arduino the choice of which _Serial_ to use is obvious.

Adding a comment to this:

`//import java.io.*;`

Will yield a helpful tip in the console that suggests what to replace the \* with:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/d/0/d083536e174c3fd9f03dd723068f8cf3f8743772.png)

`:)`
