Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8215205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:42:22+00:00 2026-06-07T11:42:22+00:00

I am running the following code to capture the live video streaming from an

  • 0

I am running the following code to capture the live video streaming from an ip camera ..it works well if I used Jframe , for some requirement I need to wrap it in applet but its not working, can anybody help please..

private static final long serialVersionUID = 1L;
public boolean useMJPGStream = false;//true;
public String jpgURL="http://192.168.x.x:80/video.cgi/jpg/image.cgi?resolution=640×480";
public String mjpgURL="http://192.168.x.x:80/video.cgi/mjpg/video.cgi?resolution=640×480";
DataInputStream dis;
private Image image = null;
public Dimension imageSize = null;
public boolean connected = false;
private boolean initCompleted = false;
HttpURLConnection huc = null;
Component parent;
/** Creates a new instance of Ax52Camera */
public void init()
{
new Thread(this).start();
}
public void connect(){
try{
URL u = new URL(useMJPGStream?mjpgURL:jpgURL);
huc = (HttpURLConnection)u.openConnection();
System.out.println(huc.getContentType());
InputStream is = huc.getInputStream();
System.out.println(is.toString());
connected = true;
BufferedInputStream bis = new BufferedInputStream(is);
dis= new DataInputStream(bis);
if (!initCompleted) initDisplay();
}catch(IOException e){ //incase no connection exists wait and try again, instead of printing the error
try{
huc.disconnect();
Thread.sleep(33);
}catch(InterruptedException ie){huc.disconnect();connect();}
connect();
}catch(Exception e){;}
}
public void initDisplay(){ //setup the display
if (useMJPGStream)readMJPGStream();
else {readJPG();disconnect();}
imageSize = new Dimension(image.getWidth(this), image.getHeight(this));
setPreferredSize(imageSize);
this.setSize(imageSize);
this.validate();
initCompleted = true;
}
public void disconnect(){
try{
if(connected){
dis.close();
connected = false;
}
}catch(Exception e){;}
}
public void paint(Graphics g) { //used to set the image on the panel
if (image != null)
g.drawImage(image, 0, 0, this);
}
public void readStream(){ //the basic method to continuously read the stream
try{
if (useMJPGStream){
while(true){
readMJPGStream();
this.repaint();
}
}
else{
while(true){
connect();
readJPG();
this.repaint();
disconnect();
}
}
}catch(Exception e){;}
}
public void readMJPGStream(){ //preprocess the mjpg stream to remove the mjpg encapsulation
readLine(3,dis); //discard the first 3 lines
readJPG();
readLine(2,dis); //discard the last two lines
}
public void readJPG(){ //read the embedded jpeg image
try{
JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(dis);
image = decoder.decodeAsBufferedImage();
}catch(Exception e){e.printStackTrace();disconnect();}
}
public void readLine(int n, DataInputStream dis){ //used to strip out the header lines
for (int i=0; i<n;i++){
readLine(dis);
}
}
public void readLine(DataInputStream dis){
try{
boolean end = false;
String lineEnd = "\n"; //assumes that the end of the line is marked with this
byte[] lineEndBytes = lineEnd.getBytes();
byte[] byteBuf = new byte[lineEndBytes.length];
while(!end){
dis.read(byteBuf,0,lineEndBytes.length);
String t = new String(byteBuf);
//System.out.print(t); //uncomment if you want to see what the lines actually look like
if(t.equals(lineEnd)) end=true;
}
}catch(Exception e){e.printStackTrace();}
}
public void run() {
connect();
readStream();
}

}

i get the following error

load: class com.javaprac.AxisCamera1.class not found.
java.lang.ClassNotFoundException: com.javaprac.AxisCamera1.class
    at sun.applet.AppletClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.applet.AppletClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.applet.AppletClassLoader.loadCode(Unknown Source)
    at sun.applet.AppletPanel.createApplet(Unknown Source)
    at sun.applet.AppletPanel.runLoader(Unknown Source)
    at sun.applet.AppletPanel.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T11:42:23+00:00Added an answer on June 7, 2026 at 11:42 am

    I was able to run this code …in the init method of applet i called the object of class and the thread like this …

    public void init() {
            ViewCamera axPanel = new ViewCamera(rootPane);
            axPanel.setOpaque(true);
            new Thread(axPanel).start();
            getContentPane().add(axPanel);
    
            // Execute a job on the event-dispatching thread; creating this applet's
            // GUI.
            try {
                SwingUtilities.invokeAndWait(new Runnable() {
                    public void run() {
    
                        createGUI();
    
                    }
                });
            } catch (Exception e) {
                System.err.println("createGUI didn't complete successfully");
            }
        }
    

    i have embed this applet in my web page as well ….

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Am running the following code to gather some data from my page and store
I am running following code to create bmp image from pdf using Ghost4j i
I'm running the following code to get a random entry from a dictionary: SELECT
Running the following code in Delphi XE2 Win32 platform works. However, the same code
Running the following code: $preCallMatch = pg_prepare($dbcp, 'callMatch', SELECT duration FROM voip_calls WHERE system_id
When running the following code, which is an easy problem, the Python interpreter works
I'm getting unexpected output when running following code, DateFormat df = new SimpleDateFormat(YYYY-MM-dd); Date
Running the following code, I get a StackOverflowError at the getPackage() line. How can
Running the following code, I get an exception: using (var client = new Pop3Client())
When running the following code I get no output but I cannot work out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.