title: How to run web-cam capture jar api in browser
body: <p>I am using following <a href="http://webcam-capture.sarxos.pl/" rel="nofollow">http://webcam-capture.sarxos.pl/</a> api to open the web camera and capture pictures using Java swing, everything works fine but the problem is its opening as a executable jar in a separate window using JFrame. But my requirement is to open the web camera in a browser. The code i am using to open the web camera as follows:</p>
  
  <pre><code>import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.awt.image.BufferedImage;
  import java.io.File;
  import java.io.IOException;
  
  import javax.imageio.ImageIO;
  import javax.swing.AbstractAction;
  import javax.swing.JButton;
  import javax.swing.JFrame;
  
  import com.github.sarxos.webcam.Webcam;
  import com.github.sarxos.webcam.WebcamPanel;
  
  
  public class WebcamPanelFillAreaExample  {
  
      public static void main(String[] args) throws InterruptedException {
  
          final Webcam webcam = Webcam.getDefault();
  
          final WebcamPanel panel = new WebcamPanel(webcam);
          //panel.setFPSDisplayed(true);
          panel.setFillArea(true);
  
          JButton button = new JButton("Capture");
          button.addActionListener(new ActionListener() {
  
              @Override
              public void actionPerformed(ActionEvent e) {
  
                  if(e.getActionCommand().equals("Capture")){
  
                      System.out.println("done::");
                      // get image
                      BufferedImage image = webcam.getImage();
  
                      // save image to PNG file
                      try {
                          ImageIO.write(image, "PNG", new File("test.png"));
  
                      } catch (IOException e1) {
                          // TODO Auto-generated catch block
                          e1.printStackTrace();
                      }
                  }
              }
          });
          JFrame window = new JFrame("Frame");
          window.add(panel);
          panel.add(button);
          window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          window.pack();
          window.setVisible(true);
  
      }
  
  
  
  
  
  }
  </code></pre>
  
  <p><strong>Libraries i am using are:</strong></p>
  
  <pre><code>1. webcam-capture-0.3.10.jar
  2. bridj-0.6.2.jar
  3. slf4j-api-1.7.2.jar
  </code></pre>
  
  <p>Kindly please help me to alter the code in order to open the webcam in a browser instead of opening through a executable jar window. Thanks in advance. Any sample piece of code would be much helpful to me.</p>