Answer the question
In order to leave comments, you need to log in
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();
}
}
}
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
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 questionAsk a Question
731 491 924 answers to any question