Here is an example of how to use Image Overlay using java2D. Since you tagged also with [jquery] I'm not sure if you want to do this using jquery or java.
I meant the 2nd Snippet, repaired and runs
import java.awt.AlphaComposite;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class WaterMark {
public static void main(String[] args) throws IOException {
URL url = new URL("http://sstatic.net/so/img/logo.png");
BufferedImage im = ImageIO.read(url);
URL url2 = new URL("http://sstatic.net/sf/img/logo.png");
BufferedImage im2 = ImageIO.read(url2);
Graphics2D g = im.createGraphics();
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f));
g.drawImage(im2, (im.getWidth()-im2.getWidth())/2, (im.getHeight()-im2.getHeight())/2, null);
g.dispose();
display(im);
ImageIO.write(im, "jpeg", new File("sample_output.jpeg"));
}
public static void display(BufferedImage image) {
JFrame f = new JFrame("WaterMark");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(new JLabel(new ImageIcon(image)));
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
}
}