|
hi,I'd like to bring you some useful stuffs,but I really don't know what the concrete problem you are puzzled.So any codes to show me or tell me the concrete topic you are trying to figure out .
|
|
|
|
|
I don't know how to start with JAVA to create random timetable without any conflict in Classes
How to start with it using Genetic Algorithm
|
|
|
|
|
You need to use Google to find references for this subject. There are many problems to be resolved in creating automatic schedules such as this, and the question is too broad for a technical forum.
Use the best guess
|
|
|
|
|
|
|
|
I want to create a server socket(TCP) in which I want that server shouldn't be closed if
client is closed.
What I'm doing: I'm able to connect to client but when client is closed then server is throwing exception : Connection Reset and crashes
How can I do it?
|
|
|
|
|
Trap the exception and dispose of it.
Use the best guess
|
|
|
|
|
I'm getting this exception:
Exception in thread "main" java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:189)
at java.net.SocketInputStream.read(SocketInputStream.java:121)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at java.io.BufferedReader.fill(BufferedReader.java:154)
at java.io.BufferedReader.readLine(BufferedReader.java:317)
at java.io.BufferedReader.readLine(BufferedReader.java:382)
at combined.Combined.dostuff(Combined.java:64)
at combined.Combined.main(Combined.java:30)
But not getting the way to dispose it.
|
|
|
|
|
Well, you need to catch it first.
Use the best guess
|
|
|
|
|
try{
}catch(SocketException e){
Sytem.err.println(e);
}
|
|
|
|
|
Indian Coder1989 wrote: I want to create a server socket(TCP) in which I want that server shouldn't be
closed if client is closed.
As stated that of course is illogical. Once the client terminates, regardless of how it happened, the server side connection can no longer be used.
|
|
|
|
|
OfCourse the server will be disconnected and connection will be closed but program shouldn't be crashed.
Isn't it possible that next time when client will again connected there will not be a need to start the server again(means server shouldn't be crashed)?
|
|
|
|
|
I already told you twice what to do: catch the exception and dispose it, so the server continues to listen in an idle state. How do you think the rest of the internet works?
Use the best guess
|
|
|
|
|
I think you should make a loop in your server code.
Just like the test code below.
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
public class Test {
public static void main(String[] args) throws Exception {
ServerSocket server = new ServerSocket(888);
while(true) {
Socket s = server.accept();
Processer p = new Processer(s);
Thread t = new Thread(p);
t.start();
}
}
}
class Processer implements Runnable {
private Socket socket;
public Processer(Socket s) {
this.socket = s;
}
@Override
public void run() {
try {
PrintWriter out=new PrintWriter(socket.getOutputStream(),true);
out.println("HTTP/1.0 200 OK");
out.println("Content-Type:text/html;charset=utf-8");
out.println();
out.println("<h1> web service test sucess!</h1>");
out.close();
} catch(Exception ex) {
ex.printStackTrace();
} finally {
try {
socket.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
To test the result,using http://127.0.0.1:888 in yor brower
Try it !
|
|
|
|
|
Thanks!
This is the thing, I was looking for.
Let me try this in my project.
|
|
|
|
|
Hello,
I have installed tomcat 6 with eclipse but now i want to install tomcat 7 with eclipse . But I keep getting the error
The Apache Tomcat installation at this directory is version 6. A tomcat 7 installation is expected.
Any idea how should i go about it.
Pritha
|
|
|
|
|
Hello Pritha,
You may find this tutorial useful in solving your issue. Also check whether CATALINA_HOME or TOMCAT_HOME environment variables are set and are pointing to wrong directory.
Regards,
Prasad P. Khandekar
Knowledge exists, man only discovers it.
|
|
|
|
|
Hi,
I have to made Windows Media Player. Can anybody suggest me how can I work on it!!
Thanx in advance
May
|
|
|
|
|
|
Hi Guys,
just wanted to know how I can build lexical and syntacitc analysis using Jlex in eclipse for generating texts !!!
any one can help me please I am stuck ??!!
Thanks in advance
|
|
|
|
|
HopePerson wrote: I am stuck With what? You need to give specific details of your problem if you want some useful suggestions.
Use the best guess
|
|
|
|
|
I'm showing or selecting images from a list.
My code for listselectionlistener is:
listener = new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
index = imageList.getSelectedIndex();
imageList.setSelectedIndex(index);
o = imageList.getSelectedValue();
if (o instanceof BufferedImage) {
imageView.setIcon(new ImageIcon((BufferedImage)o));
}
}
};
imageList.addListSelectionListener(listener);
to get next item in JList (imageList) I'm coding like this:
public void nextimage()
{
index ++;
imageList.addListSelectionListener(listener);
imageList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
imageList.setSelectedIndex(index); -----here is error: Null Pointer Exception
}
I initialize index as int index=0;
Program in starting returning right value but after 4 or 5 images it's not working.
How can I change the Item in this list?
Please suggest your opinions.
|
|
|
|
|
You need to check if the JList does contain so much values.
You're not coding safe. You need to take more care.
You can never expect a value to be there as you need it - always check if the value is valid before you use it!
|
|
|
|
|
Thanks for your quick reply.
Will you be more specific on checking the value?
As I'm selecting the value from Jlist that is showing thumbnails.
I'm not getting the exact way for selecting next item.
|
|
|
|