aspose file tools*
The moose likes Applets and the fly likes Start applet not initialised Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Start applet not initialised" Watch "Start applet not initialised" New topic
Author

Start applet not initialised

Efua Aidoo
Greenhorn

Joined: Apr 13, 2007
Posts: 1
I have compiled the following code and it compiles but when i run the code the following error message is shown in the applet window Start: Applet not initialized. Can someone please have a look at my code and say where I went wrong. Thanks

import java.net.*;
import java.io.*;

public class Clientvee
{
public static void main (String []args) throws IOException
{

Socket clientSocket;
PrintStream out = null;
BufferedReader in = null;
try
{
clientSocket = new Socket("192.168.254.2",1521);
out = new PrintStream(clientSocket.getOutputStream());
in=new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
}
catch(UnknownHostException e)
{
System.err.println("Unidentified hostname");
System.exit(1);
}
catch(IOException e)
{
System.err.println("Couldn't get I/O");
System.exit(1);
}
BufferedReader stdin = new BufferedReader(new InputStreamReader((System.in)));
String login=in.readLine(); //read from socket
System.out.println(login);
String logName=stdin.readLine(); //accepting login
out.println(logName);
String password=in.readLine(); //reading from the socket
System.out.println(password);
String pass=stdin.readLine(); //accepting password
out.println(pass);
String str=in.readLine();
System.out.println(str);
while((str = stdin.readLine()) != null)
{
out.println (str);
if(str.equals("Bye"))
break;
}

out.close();
in.close();
stdin.close();
}
}

when you compile it does not give you any error.it compiles successfully but when you run it, it gives you the window and an error behind it in DOS mode. This is the error.

java.lang.ClassCastException:Clientvee cannot be cast to java.applet.Applet
at sun.applet.AppletPanel.createApplet <AppletPanel.java:778>
at sun.applet.AppletPanel.runLoader<AppletPanel.java:707>
at sun.applet.AppletPanel.run<AppletPanel.java:361>
at java.lang.Thread.run<Thread.java:619>

please help me out in solving this error.I know and believe that you can help me out.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39578
    
  27
Welcome to JavaRanch.

What you have there is not an applet (which extends the java.applet.Applet class), but an application (which includes a main method). The ApplicationApplet class can help run an application as an applet.


Ping & DNS - updated with new look and Ping home screen widget
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Start applet not initialised
 
Similar Threads
making Thread of methods
what is the prob !!!
connection problem...
Server sending data to Clients Randomly
Decompression of strings received from socket connection