Java Tip: How to extract the content of a Jar File Using Command Prompt

To extract the files from a jar file, use x, as in:

jar xf myFile.jar

To extract only certain files from a jar file, supply their filenames:

jar xf myFile.jar foo bar
[My Video Promotion]
Tagged , , , , , , , , , , , , , , , , , . Bookmark the permalink.

One Response to How to capture a screenshot using Java and save it to a file?

  1. Pankaj says:

    sir,
    i m trying to capture image from web cam and i succeed in it, but i want now to capture and save image from camera frame per second
    plz sir help me with this

    hear is my code

    package capturewebcam;

    import java.awt.Component;
    import java.awt.Image;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.imageio.ImageIO;
    import javax.media.Buffer;
    import javax.media.CannotRealizeException;
    import javax.media.Manager;
    import javax.media.MediaLocator;
    import javax.media.NoPlayerException;
    import javax.media.Player;
    import javax.media.control.FrameGrabbingControl;
    import javax.media.format.VideoFormat;
    import javax.media.util.BufferToImage;
    import javax.swing.JLabel;

    /**
    *
    * @author depan_000
    */
    public class CaptureImage {

    Player broadcast = null;
    Image img = null;

    public Component componen()throws IOException, NoPlayerException{
    Component comp_video;
    MediaLocator loo = new MediaLocator(“vfw://0”);
    try {
    broadcast = Manager.createRealizedPlayer(loo);
    broadcast.start();
    } catch (CannotRealizeException ex) {
    Logger.getLogger(CaptureImage.class.getName()).log(Level.SEVERE, null, ex);
    }
    if((comp_video = broadcast.getVisualComponent()) != null)
    {
    comp_video.setSize(322,315);
    return comp_video;

    }
    else{

    return null;
    }

    }
    public void capture_image(){
    FrameGrabbingControl grab = (FrameGrabbingControl) broadcast.getControl(“javax.media.control.FrameGrabbingControl”);
    Buffer buff = grab.grabFrame();
    BufferToImage image = new BufferToImage((VideoFormat)buff.getFormat());
    img = image.createImage(buff);

    }
    public void set_image_label(JLabel lb){
    capture_image();
    lb.setIcon(new javax.swing.ImageIcon(img));

    }

    public void save_image(String path){
    BufferedImage image = (BufferedImage) img;
    File outputfile = new File(path);
    try {
    ImageIO.write(image, “png”, outputfile);
    } catch (IOException ex) {
    Logger.getLogger(CaptureImage.class.getName()).log(Level.SEVERE, null, ex);
    }
    }

    }

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.