我想将我的项目打包在一个可执行的JAR中进行分发.
如何将所有依赖JAR的Maven项目打包到我的输出JAR中?
如何将项目的运行时依赖项复制到target/lib文件夹中?
因为它是现在,后mvn clean install的target文件夹仅包含我的项目的罐子,但没有运行时依赖的.
我创建了一个这样的JAR文件:
jar cf Predit.jar *.*
Run Code Online (Sandbox Code Playgroud)
我通过双击它来运行这个JAR文件(它不起作用).所以我从DOS提示符运行它,如下所示:
java -jar Predit.jar
Run Code Online (Sandbox Code Playgroud)
它引发了"无法加载主类"异常.所以我解压缩了这个JAR文件:
jar -xf Predit.jar
Run Code Online (Sandbox Code Playgroud)
我运行了类文件:
java Predit
Run Code Online (Sandbox Code Playgroud)
它运作良好.我不知道为什么JAR文件不起作用.请告诉我运行JAR文件的步骤
我试图通过IntelliJ IDEA的jar工件将使用OptaPlanner 6.0.1库的项目打包到.jar中,而不是我的manifest.mf包含标准
Manifest-Version: 1.0
Main-Class: a.b.c.app
Run Code Online (Sandbox Code Playgroud)
jar使用的是ecta-3.7.2.jar中提供的一个,这是OptaPlanner的支持库之一:
Manifest-Version: 1.0
Build-Jdk: 1.6.0_26
Built-By: ibrandt
Created-By: Apache Maven
Archiver-Version: Plexus Archiver
Run Code Online (Sandbox Code Playgroud)
因此,"no main manifest attribute, in appname.jar"尝试运行应用程序时会发生错误.如果我手动将.jar文件中的清单替换为我的一切正常.有什么办法可以解决这个问题吗?
我将这些库保存在一个单独的/ lib目录中,并将它们作为Extracted Directory添加到jar工件的根目录中,IntelliJ IDEA是v13.0.1.
我在运行一个由Gradle构建的JAR文件时得到的这个错误让我很生气.错误读取"没有主要清单属性,在RxJavaDemo.jar中"我试图操纵Manifest属性,但我想我忘了添加依赖项或其他东西.我究竟做错了什么?
apply plugin: 'java'
apply plugin: 'application'
mainClassName = 'demo.MainDashboard'
dependencies {
compile files ("H:/Processes/Development/libraries/hikari-cp/HikariCP-2.4.1.jar")
compile files ("H:/Processes/Development/libraries/controls-fx/controlsfx.jar")
compile files ("H:/Processes/Development/libraries/database_connections/sqlite-jdbc-3.8.6.jar")
compile files ("H:/Processes/Development/libraries/guava/guava-18.0.jar")
compile files ("H:/Processes/Development/libraries/rxjava/rxjava-1.0.12.jar")
compile files ("H:/Processes/Development/libraries/rxjava-extras/rxjava-extras-0.5.15.jar")
compile files ("H:/Processes/Development/libraries/rxjavafx/RxJavaFX-1.0.0-RC1-SNAPSHOT.jar")
compile files ("H:/Processes/Development/libraries/rxjavaguava/rxjava-guava-1.0.3.jar")
compile files ("H:/Processes/Development/libraries/rxjava-jdbc/rxjava-jdbc-0.6.3.jar")
compile files ("H:/Processes/Development/libraries/slf4j/slf4j-api-1.7.12.jar")
compile files ("H:/Processes/Development/libraries/tom-commons/tom-commons.jar")
}
sourceSets {
main.java.srcDir "src/main/java"
main.resources.srcDir "src/main/resources"
}
jar {
manifest {
attributes(
"Class-Path": configurations.compile.collect { it.getName() }.join(' '))
}
from configurations.compile.collect { entry -> zipTree(entry) }
}
Run Code Online (Sandbox Code Playgroud) 我正在使用Java Maven程序而且我不知道要输入什么<mainClass>.我已经根据众多 stackoverflow问题尝试了各种各样的东西,但他们没有解决错误.
每次说:
Maven Error: Could not find or load main class ...
Run Code Online (Sandbox Code Playgroud)
我在里面写了这个pom.xml(减去???)
<build>
...
<plugins>
...
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/jar-with-dependencies.xml</descriptor>
</descriptors>
<archive>
<manifest>
<mainClass> ??? </mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
...
</build>
Run Code Online (Sandbox Code Playgroud)
我该如何解决这些错误?
我有一些课程说我有20个课程有不同的目标.现在我想做的是我想制作一个包含所有这些文件的jar文件.我想这样做是因为我想在其他项目中将这些类用作单个Jar.我怎样才能做到这一点?
我正在试图弄清楚如何使用Fernflower Java反编译器.
我可以java-decompiler.jar在以下位置找到:
~/idea-IC-162.1628.40/plugins/java-decompiler/lib/java-decompiler.jar
Run Code Online (Sandbox Code Playgroud)
fernflower.jar但是,没有.我认为这是因为功能已被折叠java-compiler.jar,而Fernflower README在2年内根本没有更新.
但是,当我运行以下内容时:
java -jar ~/idea-IC-162.1628.40/plugins/java-decompiler/lib/java-decompiler.jar myclassfile.class .
Run Code Online (Sandbox Code Playgroud)
我明白了
没有主要的清单属性,在/home//idea-IC-162.1628.40/plugins/java-decompiler/lib/java-decompiler.jar中
IntelliJ是否已停止支持基于命令行的反编译,或者我在这里遗漏了什么?
我最近刚刚开始在Java中使用Maven.时间来测试我的项目,它在NetBeans窗口中运行良好,运行App.java(com.MyCompany.App)中的主类,但是当我尝试从命令行运行它时,我收到一个错误:
java -jar fileName.jar
Run Code Online (Sandbox Code Playgroud)
fileName.jar中的"No Main Manifest Attribute"
我已经尝试添加一个manifest.mf文件,指定main是什么,我也已经进入项目属性并将其添加为主文件...
这是怎么回事?
我目前正在Eclipse IDE上研究selenium web驱动程序和testng.我通常从我创建的XML文件运行测试,该文件运行eclipse中的所有方法.
现在我想创建一个简单的可执行jar,它应该做同样的事情,即它的运行点应该是XML文件,以便执行每个测试.
我正在努力解决这个问题.请告诉我如何进一步了解它
java ×10
jar ×5
maven-2 ×3
maven ×2
decompiler ×1
dependencies ×1
eclipse ×1
gradle ×1
manifest ×1
manifest.mf ×1
maven-3 ×1
netbeans ×1
optaplanner ×1
selenium ×1