Не могу запустить TelegramBot проект Maven из Intellij idea в cmd windows 10

В IDE все работает. Хочу запустить в cmd Проект в cmd компилируется нормально, но При запуске есть ошибки Адрес проекта где pom

```

    C:\Users\adm\Desktop\TelegramBotMaven_CMD\source\TelegramBot

```

Создание проекта mvn

```

mvn archetype:generate
groupId = org.example
artifactId = TelegramBot
version = 1.0-SNAPSHOT
package TB;
cd TelegramBot
cd targetmvn clean install
cd target
java -cp TelegramBot-1.0-SNAPSHOT.jar TB.MainBot
    ```
    В проекте 5 классов. Я вынес main в отдельный класс без наследования. 

Pom
<?xml version="1.0" encoding="UTF-8"?>

-<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">

<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>

<artifactId>TelegramBot</artifactId>

<version>1.0-SNAPSHOT</version>

<name>TelegramBot</name>

<!-- FIXME change it to the project's website -->


<url>http://www.example.com</url>


-<properties>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<maven.compiler.source>1.7</maven.compiler.source>

<maven.compiler.target>1.7</maven.compiler.target>

</properties>


-<dependencies>


-<dependency>

<groupId>junit</groupId>

<artifactId>junit</artifactId>

<version>4.11</version>

<scope>test</scope>

</dependency>


-<dependency>

<groupId>org.telegram</groupId>

<artifactId>telegrambots</artifactId>

<version>5.0.1</version>

</dependency>


-<dependency>

<groupId>org.slf4j</groupId>

<artifactId>slf4j-nop</artifactId>

<version>1.7.13</version>

</dependency>


-<dependency>

<groupId>org.jsoup</groupId>

<artifactId>jsoup</artifactId>

<version>1.10.2</version>

</dependency>


-<dependency>

<groupId>com.github.prominence</groupId>

<artifactId>openweathermap-api</artifactId>

<version>1.2</version>

</dependency>

</dependencies>


-<build>


-<pluginManagement>

<!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->



-<plugins>

<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->



-<plugin>

<artifactId>maven-clean-plugin</artifactId>

<version>3.1.0</version>

</plugin>

<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->



-<plugin>

<artifactId>maven-resources-plugin</artifactId>

<version>3.0.2</version>

</plugin>


-<plugin>

<artifactId>maven-compiler-plugin</artifactId>

<version>3.8.0</version>

</plugin>


-<plugin>

<artifactId>maven-surefire-plugin</artifactId>

<version>2.22.1</version>

</plugin>


-<plugin>

<artifactId>maven-jar-plugin</artifactId>

<version>3.0.2</version>

</plugin>


-<plugin>

<artifactId>maven-install-plugin</artifactId>

<version>2.5.2</version>

</plugin>


-<plugin>

<artifactId>maven-deploy-plugin</artifactId>

<version>2.8.2</version>

</plugin>

<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->



-<plugin>

<artifactId>maven-site-plugin</artifactId>

<version>3.7.1</version>

</plugin>


-<plugin>

<artifactId>maven-project-info-reports-plugin</artifactId>

<version>3.0.0</version>

</plugin>

</plugins>

</pluginManagement>

</build>

</project>
  1. Класс main

    package TB;
    
    import org.telegram.telegrambots.meta.TelegramBotsApi;
    import org.telegram.telegrambots.meta.exceptions.TelegramApiException;
    import org.telegram.telegrambots.updatesreceivers.DefaultBotSession;
    
    public class MainBot {
        public static void main(String[] args) {
            try {
                TelegramBotsApi botsApi = new TelegramBotsApi(DefaultBotSession.class);
                botsApi.registerBot(Bot.getBot());
            } catch (TelegramApiException e) {
                e.printStackTrace();
            }
        }
    }

2.Сам Bot

package TB;

import org.telegram.telegrambots.bots.TelegramLongPollingBot;
import org.telegram.telegrambots.meta.TelegramBotsApi;
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
import org.telegram.telegrambots.meta.api.objects.Message;
import org.telegram.telegrambots.meta.api.objects.Update;
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;
import org.telegram.telegrambots.updatesreceivers.DefaultBotSession;

public class Bot extends TelegramLongPollingBot {
    private boolean adminUser;
    final String BOT_TOKEN = "KEY";
    final String BOT_NAME = "NAME";
    final String tokenWeather = "KEY";
    final double latitude = KORD;
    final double longitude = KORD;
    final String linkMeta = "LINK";
    final String expressionMeta = "EXPRESSION";
    private Logs logs;
    private Weather weather;
    private News news;
    public Update update;

    public Bot() {
        this.adminUser = true;
        logs = new Logs();
        weather = new Weather(this.latitude, this.longitude, this.tokenWeather);
        news = new News(this.expressionMeta, this.linkMeta, logs.newsMetaFile.getPath());
        this.update = null;
    }

    static public Bot getBot(){
        return new Bot();
    }

    @Override
    public String getBotUsername() { return BOT_NAME; }

    @Override
    public String getBotToken() {
        return BOT_TOKEN;
    }

    @Override
    public void onUpdateReceived(Update update) { //send messages in telegram

        if (this.adminUser) {
            this.adminUser = false;
            this.update = update;
            Thread startBot = new Thread(new StartBot(this), "StartBot");
            startBot.start();
        }
    }
    private void startNewsWeather(Update update){
        Message message = update.getMessage();
        SendMessage sendMessage = new SendMessage();
        sendMessage.enableMarkdown(true);
        sendMessage.setChatId(message.getChatId().toString());
        sendMessage.setReplyToMessageId(message.getMessageId());

        for( ; ; ){
            try {
                Thread.sleep(5000); // 10800000 3 hours;
                sendMessage.setText(weather.getWeather());
                execute(sendMessage);
                if(!logs.readFile(logs.newsMetaFile.getPath()).equals(news.getNewsLink())){
                    sendMessage.setText(news.getNewsLink());
                    if(sendMessage.getText().trim().length() != 0){
                        execute(sendMessage);
                        logs.setStr(news.getNewsLink());
                        logs.writeMetaFile();
                    } else{
                        logs.setStr("Error - sendMessage.getText() is empty");
                        logs.writeLogsFile();
                    }
                }
            } catch (TelegramApiException | InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    public class StartBot implements Runnable{
        private Bot bot;
        StartBot(Bot bot){
            this.bot = bot;
        }
        @Override
        public void run() {
            bot.startNewsWeather(this.bot.update);
        }
    }
}

И 3 класса логика получения данных для класса Bot

При запуске в cmd получаю ошибку java -cp TelegramBot-1.0-SNAPSHOT.jar TB.MainBot Есть подозрение что cmd использует 1,7 компилятор, а IDE 8 Возможно в это проблема. ЗАметил одну разницу, если добавляю лямбда выражения, то в cmd есть на них ошибки, что в ИДЕ не наблюдается.

C:\Users\adm>cd C:\Users\adm\Desktop\TelegramBotMaven_CMD\source\TelegramBot

C:\Users\adm\Desktop\TelegramBotMaven_CMD\source\TelegramBot>cd target

C:\Users\adm\Desktop\TelegramBotMaven_CMD\source\TelegramBot\target>java -cp TelegramBot-1.0-SNAPSHOT.jar TB.MainBot
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/telegram/telegrambots/meta/exceptions/TelegramApiException
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
        at java.lang.Class.privateGetMethodRecursive(Unknown Source)
        at java.lang.Class.getMethod0(Unknown Source)
        at java.lang.Class.getMethod(Unknown Source)
        at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
        at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.telegram.telegrambots.meta.exceptions.TelegramApiException
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 7 more

C:\Users\adm\Desktop\TelegramBotMaven_CMD\source\TelegramBot\target>

Ответы (0 шт):