IntelliJ: importiertes Package wird nicht gefunden?

Hallo,

ich habe ein kleines Test-Projekt in IntelliJ erstellt. Dazu habe ich über Project Structure -> Libraries -> Maven eine Bibliothek eingebunden. Diese finde ich auch als jar-Datei links im lib-Ordner. Will ich das Programm ausführen, erhalte ich den Compiler-Fehler, dass die von mir benutzen Packages nicht gefunden wurden.

Compiler-Ausgabe:

18:37:49: Executing task 'Main.main()'...
> Task :compileJava FAILED
C:[gekürzt]\src\main\java\Main.java:1: error: package org.firmata4j does not exist
import org.firmata4j.IODevice;
          ^
C:[gekürzt]\src\main\java\Main.java:2: error: package org.firmata4j.firmata does not exist
import org.firmata4j.firmata.FirmataDevice;
              ^
C:[gekürzt]\src\main\java\Main.java:12: error: cannot find symbol
    IODevice device = new FirmataDevice("COM3"); // using the name of a port
    ^
 symbol:  class IODevice
 location: class Main
C:[gekürzt]\src\main\java\Main.java:12: error: cannot find symbol
    IODevice device = new FirmataDevice("COM3"); // using the name of a port
               ^
 symbol:  class FirmataDevice
 location: class Main
4 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
1 actionable task: 1 executed
Compilation failed; see the compiler error output for details.
18:37:52: Task execution finished 'Main.main()'.

_____________________________________________________________________________

Warum gibt erst der Compiler den Fehler aus, dass die Packages - warum auch immer - nicht gefunden werden konnten und nicht schon IntelliJ selbst?

Mein Java-Code:

import org.firmata4j.IODevice;
import org.firmata4j.firmata.FirmataDevice;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException, InterruptedException {
    System.out.println("Moinsen!");

    IODevice device = new FirmataDevice("COM3"); // using the name of a port
    device.start(); // initiate communication to the device
    device.ensureInitializationIsDone(); // wait for initialization is done
  }
}
PC, Computer, Technik, programmieren, Java, IntelliJ IDEA

Meistgelesene Fragen zum Thema IntelliJ IDEA