public static void main(String[] args) throws NoSuchProviderException, NoSuchAlgorithmException {
    System.out.println("Starting rfid-reader2keyboard");

    Security.insertProviderAt(new Smartcardio(), 1);
    TerminalFactory.getInstance("PC/SC", null);

    System.out.println("The following terminals were detected:");
    System.out.println(Read.listTerminals());

    System.out.println();
    System.out.println(
        "inventid RFID capturing is currently active. Close this dialog to deactivate.");
    System.out.println(
        "The most likely reason you see this is in order to resolve any issue you ay have found. Please follow"
            + " the instructions of inventid support and send these lines to the given email address");

    executorService.scheduleAtFixedRate(errorLogger, 10, 30, TimeUnit.SECONDS);
    executorService.scheduleAtFixedRate(detectorLoop, 10, 15, TimeUnit.SECONDS);

    Read reader = new Read();
    reader.startRunning();

    Runtime.getRuntime()
        .addShutdownHook(
            new Thread() {
              public void run() {
                executorService.shutdownNow();
                System.out.println(
                    "inventid RFID capturing is now inactive. You can close this dialog");
              }
            });
  }
 @Override
 public void run() {
   Instant now = Instant.now();
   if (read.getLastAction() == null
       || read.getLastAction().plus(reconnectTime, ChronoUnit.SECONDS).isBefore(now)) {
     System.out.println("Reconnect due to lack of scan actions");
     read.findAndConnectToTerminal();
     read.setLastAction(now);
   }
 }
 public void run() {
   System.out.println(Read.listTerminals());
 }