让我们有一个Java应用程序,它包含在文件A.java
和B.java
中,依赖于somejar.jar
文件。问题是:使用来自cmdline的Java JAR文件
如何创建一个可自行运行的JAR文件,其中包含所有的依赖项和源代码?主要条件是仅使用标准Java实用程序(与JDK一起提供;例如:
java
,javac
和jar
)和不是任何构建工具(如Maven,Ant或任何其他)。如何在我的应用程序中使用外部JAR文件?例如,该算法是:
if the 'otherjar.jar' is present near the main application JAR, we should call method Moo::method1 from that class, passing the new instance of Foo class to it. Moo and Foo should be present in 'otherjar.jar' file. Still, the 'config.xml' file should be there too
。