Ravi Teja
Ravi Teja

Reputation: 35

How do i make a Jar file from an already existing Jar and my own classes?

For example I want to create a Jar file C.jar from A.Jar(like from rt.jar from Jre) and my own classes(Ex.java file). I am using Eclipse IDE.

Upvotes: 0

Views: 103

Answers (2)

Shreyash Samani
Shreyash Samani

Reputation: 48

  • If you want to create Jar file using eclipse then you can follow this link. Put your class files and existing A.jar then perform export operation to create C.jar.

  • If you want to create Jar file using cmd then use jar cf C.jar *.jar *.class command to create new Jar file with classes as well as existing A.jar.

Upvotes: 3

mdewit
mdewit

Reputation: 2036

If you are using maven to build your jar then you can make use of the maven-assembly-plugin. This plugin will build a jar that will contain your code as well as all packages contained in the project's dependencies. See here for the documentation: http://maven.apache.org/plugins/maven-assembly-plugin/

Upvotes: 0

Related Questions