By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,665 Members | 1,251 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,665 IT Pros & Developers. It's quick & easy.

JMF Applet problem

100+
P: 201
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.NoClassDefFoundError: javax/media/ControllerListener

at java.lang.ClassLoader.defineClass0(Native Method)

at java.lang.ClassLoader.defineClass(Unknown Source)

at java.security.SecureClassLoader.defineClass(Unknow n Source)

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.plugin.AppletViewer.createApplet(Unknown Source)

at sun.applet.AppletPanel.runLoader(Unknown Source)

at sun.applet.AppletPanel.run(Unknown Source)

at java.lang.Thread.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/.
Sep 4 '07 #1
Share this Question
Share on Google+
3 Replies


10K+
P: 13,264
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.NoClassDefFoundError: javax/media/ControllerListener

at java.lang.ClassLoader.defineClass0(Native Method)

at java.lang.ClassLoader.defineClass(Unknown Source)

at java.security.SecureClassLoader.defineClass(Unknow n Source)

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.plugin.AppletViewer.createApplet(Unknown Source)

at sun.applet.AppletPanel.runLoader(Unknown Source)

at sun.applet.AppletPanel.run(Unknown Source)

at java.lang.Thread.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
Sep 4 '07 #2

100+
P: 201
Hi
TypicalPlayerApplet.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="TypicalPlayerApplet" width=400 height=400>
<param name=file value="Video 4.avi">
</applet>


</html

TypicalPlayerApplet.java
import java.applet.Applet;
import java.awt.*;
import java.lang.String;
import java.net.URL;
import java.net.MalformedURLException;
import java.io.IOException;
import javax.media.*;

/**
<!-- Sample HTML

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

* </applet>
* -->
*/

public class TypicalPlayerApplet extends Applet implements ControllerListener
{
// media player
Player player = null;


// component in which video is playing
Component visualComponent = null;
// controls gain, position, start, stop
Component controlComponent = 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("FILE")) == 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.createPlayer(url)) == null)
Fatal("Could not create player for "+url);

// Add ourselves as a listener for player's events
player.addControllerListener(this);
}
catch (MalformedURLException u)
{
Fatal("Invalid media file URL!");
}


catch(IOException i)
{
Fatal("IO exception creating player for ");
}
catch(NoPlayerException 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.deallocate();
}
}



public synchronized void controllerUpdate(ControllerEvent 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 RealizeCompleteEvent)
{
if ((visualComponent = player.getVisualComponent()) != null)
add("Center", visualComponent);
if ((controlComponent = player.getControlPanelComponent()) != null)
add("South",controlComponent);
// force the applet to draw the components
validate();
}
else if (event instanceof CachingControlEvent)
{

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

CachingControlEvent e = (CachingControlEvent) event;
CachingControl cc = e.getCachingControl();
long cc_progress = e.getContentProgress();
long cc_length = cc.getContentLength();

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

if (progressBar == null)
if ((progressBar = cc.getProgressBarComponent()) != 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.setMediaTime(new Time(0));
player.start();
}
else if (event instanceof ControllerErrorEvent)
{
// Tell TypicalPlayerApplet.start() to call it a day

player = null;
Fatal (((ControllerErrorEvent)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.println("FATAL ERROR: " + s);
throw new Error(s); // Invoke the uncaught exception
// handler System.exit() is another
// choice
}
}
Sep 4 '07 #3

100+
P: 201
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.
Sep 5 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.