我知道这已被问过很多次了,而且我现在已经找了好几个小时但却找不到解决办法。
"错误:无法找到或加载主类bradley.discord.bot.DiscordBot"
机器人使用' Run'在IntelliJ中启动但是java -jar DiscordBot.jar
会产生上述错误。我已经设置了清单,所以我不认为这是问题所在。
清单:
Manifest-Version: 1.0
Class-Path: json-simple-1.1.jar nv-websocket-client-2.0.jar unirest-ja
va-1.4.9.jar servlet-api-2.5.jar commons-io-2.5.jar httpcore-4.4.4.ja
r base64-2.3.9.jar antlr-3.2.jar commons-logging-1.2.jar JDA-3.0.0_18
9.jar google-oauth-client-1.22.0.jar commons-codec-1.2.jar jline-0.9.
94.jar httpasyncclient-4.1.1.jar cassandra-thrift-0.8.1.jar jackson-d
atabind-2.8.5.jar google-http-client-1.22.0.jar jackson-core-asl-1.4.
0.jar guava-r08.jar jetty-util-6.1.22.jar jsoup-1.10.1.jar libthrift-
0.6.1.jar jackson-annotations-2.8.0.jar google-http-client-jackson2-1
.22.0.jar jamm-0.2.2.jar commons-lang3-3.5.jar trove4j-3.0.3.jar juni
t-4.4.jar cassandra-all-0.8.1.jar slf4j-simple-1.7.25.jar antlr-2.7.7
.jar httpcore-nio-4.4.4.jar commons-collections-3.2.1.jar jetty-6.1.2
2.jar google-api-services-youtube-v3-rev183-1.22.0.jar servlet-api-2.
5-20081211.jar antlr-runtime-3.2.jar httpmime-4.5.2.jar commons-colle
ctions4-4.1.jar commons-lang-2.6.jar avro-1.4.0-cassandra-1.jar forms
_rt-5.0.jar lavaplayer-1.2.36.jar jsr305-1.3.9.jar guava-jdk5-17.0.ja
r lavaplayer-common-1.0.4.jar google-api-client-1.22.0.jar jna-4.4.0.
jar concurrentlinkedhashmap-lru-1.1.jar jackson-mapper-asl-1.4.0.jar
json-20160810.jar stringtemplate-3.2.jar commons-cli-1.1.jar high-sca
le-lib-1.1.2.jar jackson-core-2.8.5.jar httpclient-4.5.2.jar snakeyam
l-1.6.jar slf4j-api-1.7.22.jar
Main-Class: bradley.discord.bot.DiscordBot
答案 0 :(得分:0)
尝试使用一些maven插件构建可执行jar文件,例如在一个使用maven-assembly-plugin下面构建可执行jar。
<!-- Maven Assembly Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>bradley.discord.bot.DiscordBot</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
使用生成的*.jar-with-dependencies.jar
与java -jar