Results 21 to 39 of 39
Thread: java networking problem
- 04-27-2012, 11:18 AM #21
Member
- Join Date
- Apr 2012
- Posts
- 23
- Rep Power
- 0
- 04-27-2012, 12:35 PM #22
Re: java networking problem
How are you compiling the code? You need to fix the compiler so it gives you the error messages. If you do not get the error messages there is something wrong with how you are compiling the code. If you don't fix that, then you will continue to have this kind of problem with any program that you write.
Use the javac command in the command prompt and copy and paste here the contents of the console window.i am using the same api and compilers as u use..
To copy the contents of the command prompt window:
Click on Icon in upper left corner
Select Edit
Select 'Select All' - The selection will show
Click in upper left again
Select Edit and click 'Copy'
Paste here.If you don't understand my response, don't ignore it, ask a question.
- 04-27-2012, 12:59 PM #23
Re: java networking problem
You must be using a different version of the source than what was posted. Please post the current version of your code.
If you don't understand my response, don't ignore it, ask a question.
- 04-28-2012, 11:39 AM #24
Member
- Join Date
- Apr 2012
- Posts
- 23
- Rep Power
- 0
Re: java networking problem
i am compiling in the following manner
javac <class name>.java
running in the following mannner
java <classname>
can u plz do wht i say.....plz whatever compiler errors u r getting through my program copy and paste them here...thats all....ill check them and let u know....
as for me....the program is compiling and running ABSOLUTELY FINE...
- 04-28-2012, 12:56 PM #25
Re: java networking problem
Your version of the code must be different than the one posted in post#1. Please post the current version.
I can't suggest fixes because my version does not compile.If you don't understand my response, don't ignore it, ask a question.
- 04-29-2012, 10:30 AM #26
Member
- Join Date
- Apr 2012
- Posts
- 23
- Rep Power
- 0
Re: java networking problem
forget it...i dont get wht ur trying to tell
- 04-29-2012, 10:41 AM #27
- 04-29-2012, 12:45 PM #28
Re: java networking problem
Ok, if you can won't post the current version of the code that you have, then I done.
Good luck.If you don't understand my response, don't ignore it, ask a question.
- 05-01-2012, 09:37 AM #29
Member
- Join Date
- Apr 2012
- Posts
- 23
- Rep Power
- 0
Re: java networking problem
2 things ...plz explain to me clearly wht to do....
number 1: what is the meaning of "current version of the code..?"
number 2: what steps should i take to get the "current version of the code...?"
regarding compilation and execution of my program in my computer-----
number 1: there are no compilation errors coming
number 2: there are not runtime exceptions occurring...this means the program is running fine...
regarding the output
number 1: frame is displayed...
number 2: when i am trying to copy the file contents to the frame's text area......its not working...
i need a solution for number 2....
thankyou...i appreciate it if you understand this...
- 05-01-2012, 12:41 PM #30
Re: java networking problem
By the current version I mean the version that you are using today. The code posted in post#1 does NOT compile without errors. To test the code I need a version of the code that compiles without errors.
Copy the version of the code that you are using today that you can compile without errors and and paste it here.If you don't understand my response, don't ignore it, ask a question.
- 05-02-2012, 11:37 AM #31
Member
- Join Date
- Apr 2012
- Posts
- 23
- Rep Power
- 0
Re: java networking problem
but i have posted the current version only.....initially whichever program i have posted is the one without any errors
- 05-02-2012, 01:12 PM #32
Re: java networking problem
Please post the code that you are now using. Is there a problem that you can not post the code that you are currently using?
The posted code does not compile without errors.
If you want any help, you should post the code. Otherwise you are wasting time.If you don't understand my response, don't ignore it, ask a question.
- 05-02-2012, 03:28 PM #33
Member
- Join Date
- Apr 2012
- Posts
- 23
- Rep Power
- 0
Re: java networking problem
import java.io.IOException;
import java.io.PrintStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.io.*;
public class MultiThreadServer implements Runnable {
Socket csocket;
MultiThreadServer(Socket csocket) {
this.csocket = csocket;
}
public static void main(String args[])
throws Exception {
ServerSocket ssock = new ServerSocket(1234);
System.out.println("Listening");
while (true) {
Socket sock = ssock.accept();
System.out.println("Connected");
new Thread(new MultiThreadServer(sock)).start();
}
}
public void run() {
System.out.println("entered in run");
try {
System.out.println("entered in run try");
byte[] mybytearray = new byte[1024];
InputStream is = sock.getInputStream();
File file = new File("D:/MyProject/src/Sumanth/WebServer/AnuFileServer/mani.txt");
FileOutputStream fos = new FileOutputStream(file);
BufferedOutputStream bos = new BufferedOutputStream(fos);
int bytesread = is.read(mybytearray,0,bytesRead);
bos.write(mybytearray,0,bytesread);
System.out.println("bos object"+bos);
bos.close();
}
catch (IOException e) {
System.out.println(e);
}
}
}
//*********************this is client program**************
import java.net.*;
import java.lang.reflect.*;
import java.lang.Class;
import java.io.*;
import java.awt.event.*;
import java.awt.*;
import java.util.*;
import org.apache.commons.io.FileUtils;
public class Client2Using extends Frame implements ActionListener{
Button b1,b2,b3;Socket socket;
TextArea t;
TextField text;
public Client2Using(){
setLayout(new FlowLayout());
b1 = new Button("start server");
b2 = new Button("File Upload");
b3 = new Button("Show File Contents");
t = new TextArea(10,10);
text = new TextField();
this.add(text);
b1.addActionListener(this);
b3.addActionListener(this);
add(t);
add(b1);
add(b2);
add(b3);
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==b1){
met();
}
if(e.getSource()==b3){
met1();
}
}
public void met(){
System.out.println("gfskjdfgksdfgkfd");
try{
Socket socket = new Socket("localhost",1234);
this.socket = socket;
System.out.println("Server Started");
}catch(Exception e){e.printStackTrace();}
}
public void met1(){
try{
File myfile = new File("D:/MyProject/src/Sumanth/WebServer/MyFrame.java");
byte[] mybytearray = new byte[(int) myfile.length()];
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(myfile));
bis.read(mybytearray,0,mybytearray.length);
OutputStream os = socket.getOutputStream();
os.write(mybytearray,0,mybytearray.length);
os.flush();
System.out.println("os object"+os);
}catch(Exception e){e.printStackTrace();}
}
public static void main(String args[]){
Client2Using f = new Client2Using();
f.setVisible(true);
f.setSize(100,100);
}
}
- 05-02-2012, 03:36 PM #34
Re: java networking problem
Please see the first response in this thread.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 05-02-2012, 03:59 PM #35
Re: java networking problem
Here is an indication of the errors I get. I does you no good if I give you the specfics on these. YOU MUST get these errors to be able to fix this code and any other code you work on in the future.
Running: D:\Java\jdk1.6.0_29\bin\javac.exe -Xlint MultiThreadServer.java
MultiThreadServer.java:xx: cannot find symbol
symbol : variable xxx
location: class MultiThreadServer
MultiThreadServer.java:xx: cannot find symbol
symbol : variable xxxx
location: class MultiThreadServer
2 errors
3 error(s)Last edited by Norm; 05-02-2012 at 04:02 PM.
If you don't understand my response, don't ignore it, ask a question.
- 05-03-2012, 03:43 AM #36
Member
- Join Date
- Apr 2012
- Posts
- 23
- Rep Power
- 0
Re: java networking problem
mr norm ......" cannot find symbol " occurs when u dont set the classpath to the classes folder or when the path variable is not set properly....or sometimes when u dont import the packages properly....at first in ur computer plz check whether u have set the classpath and the path variable properly to the required java bin folders....set the classpath in environment variables.....
what is variable xxx...?.i have not defined any variable xxx in my program..? which variable was it...?..and plz compile and run the client program seperately and the server program seperately..that is in one text document type copy the client program...in another text document copy the server program...
plz mention the variable name....compiler only recognises the packages and the variables only when it knows how to communicate with the java software....plz make sure u have installed the java software properly and set the path variable....
how can i fix errors when they r not occuring in my computer...i am trying to explain the same thing to u since days ..that the above program which i have posted works fine in my computer...it compiles ....without any errors...
- 05-03-2012, 03:47 AM #37
Member
- Join Date
- Apr 2012
- Posts
- 23
- Rep Power
- 0
Re: java networking problem
classnotfoundexception occurs when classpath is not set properly...cannot find symbol occurs when the compiler is not able to communicate with the required java files or jar files....plz make sure u have set the path and the classpath variable properly...
- 05-03-2012, 03:48 AM #38
Member
- Join Date
- Apr 2012
- Posts
- 23
- Rep Power
- 0
Re: java networking problem
the problem is in ur computer...not mine
- 05-03-2012, 03:49 AM #39
Similar Threads
-
Networking with java
By munny in forum NetworkingReplies: 8Last Post: 11-20-2011, 04:30 AM -
New to networking in java...
By jigglywiggly in forum New To JavaReplies: 4Last Post: 05-25-2010, 08:10 AM -
networking problem
By anurupr in forum NetworkingReplies: 0Last Post: 03-15-2010, 03:53 PM -
Java networking.
By tim in forum New To JavaReplies: 7Last Post: 07-16-2009, 10:43 PM -
Networking Problem
By Ambuscade in forum NetworkingReplies: 21Last Post: 11-05-2008, 03:12 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks