Question : Can't Import javax.tv.Xlet within Java ME project class

Anyone please help I'm making newXlet class and I have the problem showed that package javax.tv.Xlet doesn't exist, and I couldn't import it to the class, what should i do?

The below is a sample code of which I couldn't follow them to the inital problem as stated.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
// In this case, everything we need is in the javax.tv.xlet package.  For more complex
// examples we would also import classes from org.dvb.* and the other MHP or Java APIs.
import javax.tv.xlet.*;

// The main class of every Xlet must implement this interface - if it doesn't do this,
// the MHP middleware can't run it.
public class FirstXletExample implements javax.tv.xlet.Xlet
{

	// Every Xlet has an Xlet context, just like the Applet context that applets in a
	// web page are given.  This is created by the MHP middleware and passed in to the
	// Xlet as a parameter to the initXlet() method.
	private javax.tv.xlet.XletContext context;

	// A private field to hold the current state.  This is needed because the startXlet()
	// method is called both to start the Xlet for the first time and also to make the
	// Xlet resume from the paused state.  This filed lets us keep track of whether we're
	// starting for the first time.
	private boolean hasBeenStarted;

	/**
	 * Every Xlet should have a default constructor that takes no arguments.
	 * No other constructor will get called.
	 */
	public FirstXletExample()
	{
		// The constructor should contain nothing.  Any initialisation
		// should be done in the initXlet() method, or in the startXlet method
		// if it's time- or resource-intensive.  That way, the MHP middleware
		// can control when the initialisation happens in a much more predictable
		// way
	}

	/**
	 * Initialise the Xlet.  The context for this Xlet will get passed in to this
	 * method, and a reference to it should be stored in case it's needed later.
	 * This is the place where any initialisation should be done, unless it takes
	 * a lot of time or resources.  If something goes wrong, then an
	 * XletStateChangeException should get thrown to let the runtime system know
	 * that the Xlet can't be initialised.
	 */
	public void initXlet(javax.tv.xlet.XletContext context) throws javax.tv.xlet.XletStateChangeException
	{
		// store a reference to the Xlet context that the Xlet is executing in
		this.context = context;

		// The Xlet has not yet been started for the first time, so set
		// this variable to false.
		hasBeenStarted = false;

		// Since this is a simple Xlet, we'll just print a message to the debug output
		System.out.println("The initXlet() method has been called.  Our Xlet context is " + context);

	}

    /**
     * Start the Xlet.  At this point the Xlet can display itself on the screen and
     * start interacting with the user, or do any resource-intensive tasks.  These
     * kinds of function should be kept in startXlet(), and should *not* be done
     * in initXlet().
     *
     * As with initXlet(), if there is any problem this method should throw an
     * XletStateChangeException to tell the runtime system that it can't start.
     *
     * One of the common pitfalls is that the startXlet() method must return to its
     * caller.  This means that the main functions of the Xlet should be done in
     * another thread. The startXlet() method should really just create that thread
     * and start it, then return.
     */
	public void startXlet() throws javax.tv.xlet.XletStateChangeException
	{
		// Again, we print a message on the debug output to tell the user that
		// something is happening.  In this case, what we print depends on
		// whether the Xlet is starting for the first time, or whether it's
		// been paused and is resuming

		// have we been started?
		if (hasBeenStarted) {
			System.out.println("The startXlet() method has been called to resume the Xlet after it's been paused.  Hello again, world!");
		}
		else {
			System.out.println("The startXlet() method has been called to start the Xlet for the first time.  Hello, world!");

			// set the variable that tells us we have actually been started
			hasBeenStarted = true;
		}
	}

	/**
	 * Pause the Xlet.  Unfortunately, it's not clear to anyone (including the
	 * folks who wrote the MHP specification) what this means.  Generally, it
	 * means that the Xlet should free any scarce resources that it's using,
	 * stop any unnecessary threads and remove itself from the screen.
	 *
	 * Unlike the other methods, pauseXlet() can't throw an exception to indicate
	 * a problem with changing state.  When the Xlet is told  to pause itself, it
	 * must do that.
	 */
	public void pauseXlet()
	{
		// Since we have nothing to pause, we will tell the user that we are
		// pausing by printing a message on the debug output.
		System.out.println("The pauseXlet() method has been called.  Bedtime...");
	}

	/**
	 * Stop the Xlet.  The boolean parameter tells the method whether the Xlet has to
	 * obey this request.  If the value of the parameter is true, the Xlet must terminate
	 * and the runtime system will assume that when the method returns, the Xlet has
	 * terminated.  If the value f the parameter is false, the Xlet can request that it
	 * not be killed, by throwing an XletStateChangeException.  if the MHP middleware
	 * still wants to kill the Xlet, it shoudl call destroyXlet() again with the
	 * parameter set to true.
	 */
	public void destroyXlet(boolean unconditional) throws javax.tv.xlet.XletStateChangeException
	{

		if (unconditional) {
			// We have been ordered to terminate, so we obey the order politely and release any
			//scarce resources that we are holding.
			System.out.println("The destroyXlet() method has been called telling the Xlet to stop unconditionally.  Goodbye, cruel world!");
		}
		else {
			// We have had a polite request to die, so we can refuse this request if we want.
			System.out.println("The destroyXlet() method has been called requesting that the application stops, but giving it the choice.  So, I'll decide not to stop.");

			// Throwing an XletStateChangeException tells the MHP middleware that the
			// application would like to keep running if it's allowed to.
			throw new XletStateChangeException("Please don't kill me!");
		}
	}
}

Answer : Can't Import javax.tv.Xlet within Java ME project class

I haven't messed too much with Java TV API, but if you are getting the error message you are then you have probably not downloaded the proper JAR and/or have not yet put that JAR in the build path of the Netbeans project in which you are trying to import it.
Random Solutions  
 
programming4us programming4us