I have a jar file and a class file. I want to create a single JAR file from both. Is it possible? Please help me on the same. I have tried Jar -cf new.jar sample1.class sample2.jar
It didnot help
I have a jar file and a class file. I want to create a single JAR file from both. Is it possible? Please help me on the same. I have tried Jar -cf new.jar sample1.class sample2.jar
It didnot help
Transfer all your classes into a folder, say it is in C:\Folder\Project\
Go to the same folder from command prompt. And execute the following code :
jar cfv Project.jar *
In the above command, c will create jar
, f will transfer the content into the file i.e Project.jar
and v will print the process done into the console
.
* (WildCard)
will take all the files present in the folder and the corresponding jar would be created in the same folder.
You can find more information the DOCS. http://docs.oracle.com/javase/tutorial/deployment/jar/basicsindex.html
In the meanwhile i would suggest you to go through the below link, where you can do the same with a build tool like Ant or Maven.
Not sure what you are trying to do, but technically you can do it with:
cp sample2.jar new.jar
jar uvf new.jar sample1.class
Of course, if you already had class sample1.class inside sample2.jar, it will be overwritten ( "u" == update ) by sample1.class