Win a copy of Terraform in Action this week in the Cloud forum!

Roan Kaas

Greenhorn
+ Follow
since Jul 23, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Roan Kaas

Ok. I've copied this script from a book but i can't seem to get it to work :'(
I've added debug printouts just to see where the program goes. The server will connect to the client and the server SEEMS to send data but my client either doesn't get it or i'm coding it wronge. Please help

[Server Code]
import java.io.*;
import java.net.*;

public class Main_Server
{
String advice = "Welcome";

public void go()
{
System.out.println("Server Started");
try{

ServerSocket serverSocket = new ServerSocket(5000);

while(true)
{
Socket sock = serverSocket.accept();

PrintWriter writer = new PrintWriter(sock.getOutputStream());
writer.println("Hello");
System.out.println("Data Sent");
}
}
catch(IOException ex)
{
ex.printStackTrace();
}
}


public static void main(String[] args)
{
System.out.println("Starting Server");
Main_Server server = new Main_Server();
server.go();
System.out.println("Server Terminated");
}
}


[Client Code]
import java.io.*;
import java.net.*;

public class Client {

/** Creates a new instance of Main */
public void go() {
System.out.println("Waitng for data...");
try{
Socket s = new Socket("127.0.0.1",5000);
InputStreamReader streamReader = new InputStreamReader(s.getInputStream());
BufferedReader reader = new BufferedReader(streamReader);
System.out.println("Got Data:");
String advice = reader.readLine();
System.out.println(":" + advice + ":");
reader.close();

}
catch(IOException ex)
{
System.out.println("An Error Has Occured! Please report the following to diablodemorte@hotmail.com:");
ex.printStackTrace();


}
//}
}

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
System.out.println("Running...");
System.out.println("Attempting to connect the Master Server of holy awsomeness");
Client client = new Client();
client.go();
System.out.println("Terminated");
}

}





Regards,
Roan


P.S> Thanx in advance
Ok. Thank you for that site. I now only have one problem. When I try to create a normal CLASS file and run it it doesn't work if i've used import.awt.*; or import.awt.event.*;

Yet when I do the same but make it an applet it runs FINE. What am i doing wronge. As i said if those two import's arn't there the command line runs fine
16 years ago
Ok. I have found this error EVERYwhere but I am unable to fix my problem


Ok. I bought this java book. And in the book I'm suppose to download Java. So i do that. Now, I've created a .JAVA file that complies into PARTY.class. Now the java main folder is C:\JAVA. The .Class and the .JAVA file are located in C:\Java2. Now BOTH of those folders and C:\JAVA\Bin are placed in both PATH and CLASSPATH. AS I said it complies but it WILL not run. I get a "Exception in thread "main" java.lang.NoClassDefFoundError: Party/class" error. This may be simple to fix but I'm a noob so PLEASE be patient and give me a step by step. I have become very frusterated with this. If java is this hard to set up how do the Java creators hope to spread popularity of their product?!

Regards,
Roan

[ July 23, 2005: Message edited by: Roan Kaas ]
[ July 23, 2005: Message edited by: Roan Kaas ]
16 years ago