简体   繁体   English

如何从命令行使用jarjar?

[英]How to use jarjar from the command-line?

I'm having trouble using jarjar from the command-line to combine a simple Scala program with the scala runtime-library. 我无法从命令行使用jarjar将简单的Scala程序与scala运行时库结合起来。

jarjar correctly detects the dependency: jarjar正确检测依赖:

$ java -jar ~/Desktop/saug/jarjar-1.0.jar find jar BCT.jar scala-library.jar
/home/schani/Work/scala/bct/BCT.jar -> /home/schani/Work/scala/bct/scala-library.jar

Combining them doesn't work, however: 但是,将它们组合起来并不起作用:

$ CLASSPATH=./scala-library.jar java -jar ~/Desktop/saug/jarjar-1.0.jar process rules.jjl BCT.jar BCTS.jar

The jar file that I get still depends on scala-library.jar. 我得到的jar文件仍然依赖于scala-library.jar。 Whether or not I add the CLASSPATH variable makes no difference. 我是否添加CLASSPATH变量没有任何区别。 My rules.jjl file looks like this: 我的rules.jjl文件如下所示:

keep BCT

What to do? 该怎么办?

Using the java "-jar" option ignores the classpath. 使用java“-jar”选项忽略类路径。 Try specifying the main class explicitly with a classpath, and omit "-jar": 尝试使用类路径显式指定主类,并省略“-jar”:

java -cp ~/Desktop/saug/jarjar-1.0.jar:./scala-library.jar com.tonicsystems.jarjar.Main process rules.jjl BCT.jar BCTS.jar

Try adding a keep for the scala.runtime.Nothing$ class. 尝试为scala.runtime.Nothing $ class添加一个keep。 I found this necessary when using a similar product (autojar; http://autojar.sourceforge.net/en_d/index.html ) with Scala. 当我使用Scala的类似产品(autojar; http://autojar.sourceforge.net/en_d/index.html )时,我发现这是必要的。

jarjar does not repackage other jars into your jar. jarjar不会将其他罐子重新包装到你的罐子里。 It only renames dependencies inside the one jar itself. 它只重命名一个jar本身内的依赖项。

Use the method outlined here Clean way to combine multiple jars? 使用此处概述的方法清洁方式组合多个罐子? Preferably using Ant to rejar all the dependent jars into your jar, then run jarjar to prevent future dependency hell. 最好使用Ant将所有依赖的罐子重新装入你的罐子里,然后运行jarjar以防止将来的依赖性地狱。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM