5

I have extracted a jar file and made some change on it. Now, how can i compress again it as an executable jar file?

Thanks.(Sorry for my bad english.)

Fatih Yakut
  • 301
  • 1
  • 4
  • 16
  • Hopefully this [answer](http://stackoverflow.com/a/9613766/1057230) be of some help on the topic :-) – nIcE cOw Jun 18 '14 at 07:35

4 Answers4

7

Try :

jar cf jar-file input-file(s)

according to http://docs.oracle.com/javase/tutorial/deployment/jar/build.html

Kasper Ziemianek
  • 1,329
  • 8
  • 15
1

By Using Eclipse IDE You can Create your jar file

Below i have one link from which you can learn how to make jar file executable

https://www.cs.utexas.edu/~scottm/cs307/handouts/Eclipse%20Help/jarInEclipse.htm

But For that You have to make project in Eclipse.

Nirav Prajapati
  • 2,987
  • 27
  • 32
0

You can use this very simple library to pack/unpack jar file programmaticaly

JarManager

Very simple

import java.io.File;
import java.util.List;

import fr.stevecohen.jarmanager.JarUnpacker;

class Test {
   JarUnpacker jarUnpacker = new JarUnpacker(); 
   File myfile = new File("./myfile.jar");
   File unpackDir = new File("./mydir");

   List<File> unpacked_files = jarUnpacker.unpack(myfile.getAbsolutePath(), unpackDir.getAbsolutePath());
}

You can also use maven dependency

<dependency>
    <groupId>fr.stevecohen.jarmanager</groupId>
    <artifactId>JarManager</artifactId>
    <version>0.5.0</version>
</dependency>

Check the last version with the link bellow to use the last dependency

Please use my public issue tracker if you find some bugs

ReaperSoon
  • 765
  • 7
  • 23
0
jar cvf filename.jar *
  • To compress all extracted file to single jar file you can use *
  • To add single file you also can use filename instead of *

https://docs.oracle.com/javase/tutorial/deployment/jar/appman.html