P
P
progerstas2022-04-10 20:14:00
Java
progerstas, 2022-04-10 20:14:00

Why doesn't the java telegram bot start?

I am trying to create a simple telegram bot using this library: https://github.com/rubenlagus/TelegramBots/
But when I run it I get an error:
java: cannot access java.util.concurrent.CompletableFuture
class file for java.util.concurrent.CompletableFuture not found

I connect the library using Maven
Here is the TelegramBotApp code (to start the bot):

package ESCTB;

import ESCTB.bot.TelegramBot;
import org.telegram.telegrambots.meta.TelegramBotsApi;
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;
import org.telegram.telegrambots.updatesreceivers.DefaultBotSession;

public class TelegramBotApp {
    public static void main(String[] args) {
        try {
            // Create the TelegramBotsApi object to register your bots
            TelegramBotsApi botsApi = new TelegramBotsApi(DefaultBotSession.class);

            // Register your newly created AbilityBot
            botsApi.registerBot(new TelegramBot());
        } catch (TelegramApiException e) {
            e.printStackTrace();
        }
    }
}


and here is the code of the bot itself (TelegramBot):
package ESCTB.bot;

import org.telegram.telegrambots.bots.TelegramLongPollingBot;
import org.telegram.telegrambots.meta.api.objects.Update;

public class TelegramBot extends TelegramLongPollingBot {
    @Override
    public void onUpdateReceived(Update update) {
        // TODO
    }

    @Override
    public String getBotUsername() {
        return "bot_name";
    }

    @Override
    public String getBotToken() {
        return "token";
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2022-04-10
@progerstas

CompletableFuture has been in Java since version 8, and you are completable in version 6.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question