javaprocessingprocessing-ide

Import Processing Serial library into java file


So I have .pde file and several .java files that are used in a project. I import the library as so into a .java file:

import processing.serial.*;

When I import the Processing serial library in the .pde file it works fine, but when I import the Processing serial library into a .java file I get this error:

The package "processing.serial" does not exist. You might be missing a library

Libraries must be installed in a folder named 'libraries' inside the sketchbook folder (see the Preferences window).

Do I need to install the library to be able to use it with a .java file or is there another solution to import the Processing serial library into a .java file?


Solution

  • Libraries don't come automatically included with Processing. You have to add them to your sketch using the Sketch > Import Library menu. This is true whether you're in the main sketch file or in a .java tab.

    Shameless self-promotion: here is a tutorial on using libraries in Processing.