public static void jar(File directory, File jarfile)
	{
		try
		{
			final URI base = directory.toURI();
			final Deque<File> queue = new LinkedList<File>();
			queue.push(directory);
			final OutputStream out = new FileOutputStream(jarfile);
			Closeable res = null;
			final JarOutputStream zout = new JarOutputStream(out);
			res = zout;

			while (!queue.isEmpty())
			{
				directory = queue.pop();

				for (final File kid : directory.listFiles())
				{
					String name = base.relativize(kid.toURI()).getPath();
					if (kid.isDirectory())
					{
						queue.push(kid);
						name = name.endsWith("/") ? name : name + "/";
						zout.putNextEntry(new JarEntry(name));
					}
					else
					{
						zout.putNextEntry(new JarEntry(name));
						copy(kid, zout);
						zout.closeEntry();
					}
				}
			}
			res.close();
		}
		catch (final IOException e)
		{
			e.printStackTrace();
		}
	}