JMF Applet problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • praveen2gupta
    New Member
    • May 2007
    • 200

    #1

    JMF Applet problem

    Hi
    I am working on JMF applets.

    My problem is that the Applet runs successfully in the appletviewer.
    But when i run it using any browser it shows Appled Loading Failed Error
    In Firefox and Netscape ,

    The Java Console shows following error

    java.lang.NoCla ssDefFoundError : javax/media/ControllerListe ner

    at java.lang.Class Loader.defineCl ass0(Native Method)

    at java.lang.Class Loader.defineCl ass(Unknown Source)

    at java.security.S ecureClassLoade r.defineClass(U nknown Source)

    at sun.applet.Appl etClassLoader.f indClass(Unknow n Source)

    at java.lang.Class Loader.loadClas s(Unknown Source)

    at sun.applet.Appl etClassLoader.l oadClass(Unknow n Source)

    at java.lang.Class Loader.loadClas s(Unknown Source)

    at sun.applet.Appl etClassLoader.l oadCode(Unknown Source)

    at sun.applet.Appl etPanel.createA pplet(Unknown Source)

    at sun.plugin.Appl etViewer.create Applet(Unknown Source)

    at sun.applet.Appl etPanel.runLoad er(Unknown Source)

    at sun.applet.Appl etPanel.run(Unk nown Source)

    at java.lang.Threa d.run(Unknown Source)

    My ClassPath settings are
    echo %CLASSPATH%
    C:\Program Files\JMF2.1.1e \lib\jmf.jar;

    I have copied and paste jmf.jar files in to run time environment
    jar/lib/.
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by praveen2gupta
    Hi
    I am working on JMF applets.

    My problem is that the Applet runs successfully in the appletviewer.
    But when i run it using any browser it shows Appled Loading Failed Error
    In Firefox and Netscape ,

    The Java Console shows following error

    java.lang.NoCla ssDefFoundError : javax/media/ControllerListe ner

    at java.lang.Class Loader.defineCl ass0(Native Method)

    at java.lang.Class Loader.defineCl ass(Unknown Source)

    at java.security.S ecureClassLoade r.defineClass(U nknown Source)

    at sun.applet.Appl etClassLoader.f indClass(Unknow n Source)

    at java.lang.Class Loader.loadClas s(Unknown Source)

    at sun.applet.Appl etClassLoader.l oadClass(Unknow n Source)

    at java.lang.Class Loader.loadClas s(Unknown Source)

    at sun.applet.Appl etClassLoader.l oadCode(Unknown Source)

    at sun.applet.Appl etPanel.createA pplet(Unknown Source)

    at sun.plugin.Appl etViewer.create Applet(Unknown Source)

    at sun.applet.Appl etPanel.runLoad er(Unknown Source)

    at sun.applet.Appl etPanel.run(Unk nown Source)

    at java.lang.Threa d.run(Unknown Source)

    My ClassPath settings are
    echo %CLASSPATH%
    C:\Program Files\JMF2.1.1e \lib\jmf.jar;

    I have copied and paste jmf.jar files in to run time environment
    jar/lib/.
    Let's see your applet tags

    Comment

    • praveen2gupta
      New Member
      • May 2007
      • 200

      #3
      Hi
      TypicalPlayerAp plet.html

      <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
      <html>
      <head><meta http-equiv="content-type" content="text/html; charset=UTF-8">

      <title> Video Mail Player</title>
      </head>

      <body>
      <applet code="TypicalPl ayerApplet" width=400 height=400>
      <param name=file value="Video 4.avi">
      </applet>


      </html

      TypicalPlayerAp plet.java
      import java.applet.App let;
      import java.awt.*;
      import java.lang.Strin g;
      import java.net.URL;
      import java.net.Malfor medURLException ;
      import java.io.IOExcep tion;
      import javax.media.*;

      /**
      <!-- Sample HTML

      <applet code=TypicalPla yerApplet width=400 height=400>
      <param name=File value="Video 4.avi">

      * </applet>
      * -->
      */

      public class TypicalPlayerAp plet extends Applet implements ControllerListe ner
      {
      // media player
      Player player = null;


      // component in which video is playing
      Component visualComponent = null;
      // controls gain, position, start, stop
      Component controlComponen t = null;
      // displays progress during download
      Component progressBar = null;


      public void init()
      {
      // setLayout(new BorderLayout()) ;
      String mediaFile = null;

      String url1= "http://localhost:8092" ;
      // URL for doc containing applet

      // Get the media filename info.
      // The applet tag should contain the path to the
      // source media file, relative to the html page.

      if ((mediaFile = getParameter("F ILE")) == null)
      Fatal("Invalid media file parameter");

      try
      {
      URL url= new URL(url1);
      URL codeBase = getDocumentBase ();

      // Create an url from the file name and the url to the
      // document containing this applet.

      if ((url = new URL(codeBase, mediaFile)) == null)
      Fatal("Can't build URL for " + mediaFile);

      // Create an instance of a player for this media
      if ((player = Manager.createP layer(url)) == null)
      Fatal("Could not create player for "+url);

      // Add ourselves as a listener for player's events
      player.addContr ollerListener(t his);
      }
      catch (MalformedURLEx ception u)
      {
      Fatal("Invalid media file URL!");
      }


      catch(IOExcepti on i)
      {
      Fatal("IO exception creating player for ");
      }
      catch(NoPlayerE xception j)
      {
      Fatal("IO exception creating player for ");
      }

      }


      public void start()
      {
      // Call start() to prefetch and start the player.

      if (player != null) player.start();
      }


      public void stop()
      {
      if (player != null)
      {
      player.stop();
      player.dealloca te();
      }
      }



      public synchronized void controllerUpdat e(ControllerEve nt event)
      {
      // If we're getting messages from a dead player,


      // just leave

      if (player == null) return;

      // When the player is Realized, get the visual
      // and control components and add them to the Applet

      if (event instanceof RealizeComplete Event)
      {
      if ((visualCompone nt = player.getVisua lComponent()) != null)
      add("Center", visualComponent );
      if ((controlCompon ent = player.getContr olPanelComponen t()) != null)
      add("South",con trolComponent);
      // force the applet to draw the components
      validate();
      }
      else if (event instanceof CachingControlE vent)
      {

      // Put a progress bar up when downloading starts,
      // take it down when downloading ends.

      CachingControlE vent e = (CachingControl Event) event;
      CachingControl cc = e.getCachingCon trol();
      long cc_progress = e.getContentPro gress();
      long cc_length = cc.getContentLe ngth();

      // Add the bar if not already there ...

      if (progressBar == null)
      if ((progressBar = cc.getProgressB arComponent()) != null)
      {
      add("North", progressBar);
      validate();
      }

      // Remove bar when finished ownloading
      if (progressBar != null)
      if (cc_progress == cc_length)
      {
      remove (progressBar);
      progressBar = null;
      validate();
      }
      }
      else if (event instanceof EndOfMediaEvent )
      {


      // We've reached the end of the media; rewind and
      // start over

      player.setMedia Time(new Time(0));
      player.start();
      }
      else if (event instanceof ControllerError Event)
      {
      // Tell TypicalPlayerAp plet.start() to call it a day

      player = null;
      Fatal (((ControllerEr rorEvent)event) .getMessage());
      }
      }

      void Fatal (String s)
      {
      // Applications will make various choices about what
      // to do here. We print a message and then exit

      System.err.prin tln("FATAL ERROR: " + s);
      throw new Error(s); // Invoke the uncaught exception
      // handler System.exit() is another
      // choice
      }
      }

      Comment

      • praveen2gupta
        New Member
        • May 2007
        • 200

        #4
        Hi
        The problem is solved now. The applets do not access your classpath so the jmf.jar file is not access and applet shows the errors. To solve the problem define the copy and paste jmf.jar file in the currect folder and define it in archive tag of html file.

        Comment

        Working...