|
1
modified 9-Dec-18 15:29pm.
|
|
|
|
|
|
Hi,
I'll start with the code for both server and client, it is just a simple example:
Server
serverSocket = new ServerSocket(4554);
serverRunning = true;
while (serverRunning) {
socket = serverSocket.accept();
ObjectOutputStream dataOut = new ObjectOutputStream(socket.getOutputStream());
ObjectInputStream dataIn = new ObjectInputStream(socket.getInputStream());
System.out.println("Done 1");
String string = dataIn.readUTF();
System.out.println("Done 2");
int number = dataIn.readInt();
System.out.println("Done 3");
dataOut.writeUTF("String from server");
System.out.println("Done 4");
dataOut.writeInt(1);
System.out.println("Done 5");
System.out.println(string + " | " + number);
}
Client
Socket socket = new Socket("localhost", 4554);
ObjectOutputStream dataOut = new ObjectOutputStream(socket.getOutputStream());
ObjectInputStream dataIn = new ObjectInputStream(socket.getInputStream());
System.out.println("Done 1");
dataOut.writeUTF("String from client");
System.out.println("Done 2");
dataOut.writeInt(2);
System.out.println("Done 3");
String string = dataIn.readUTF();
System.out.println("Done 4");
int number = dataIn.readInt();
System.out.println("Done 5");
socket.close();
System.out.println(string + " | " + number);
According to java Object Serialization, you need to create the ObjectOutputStream before ObjectInputStream in both Server and Client side, which I did, but the Client will run until it gets to the point of having to wait for data from the server (print the message "Done 3" then wait), but on the Server side, the code only runs until it gets to the point of reading the first thing from the Client (print "Done 1" then wait).
What else I need to do, beside creating the ObjectOutputStream before ObjectInputStream?
modified 4-Dec-18 10:49am.
|
|
|
|
|
how to trace local pc by IP address and and analysis data collection
|
|
|
|
|
|
Quote: When should i use and what? Where as i know we can connect MQ queue and JMS queue by using JMS API.
cabn you please help me out for this?
|
|
|
|
|
GiteHrudaya wrote: help me out for this? With what? your question is not clear.
|
|
|
|
|
Hi,
My project depends highly to database as it reads a lot of configs or metadata (some times constant values!) from data base so if some of this values are missing in DB the code fails,I'm looking for a best practice to write a test(or may be a kind of unit test) to check if these values exist in db (on customer servers)
any help or idea would be appreciated
modified 1-Dec-18 3:53am.
|
|
|
|
|
|
thank you for reply, by now I'm using TestNg, my problem is this case seems to be some thing between integration test and unit test and I have no idea how to test this issue
|
|
|
|
|
If this is to check the customer's database then the application just needs a list of elements that should exist. It then requests each one from the database and raises some form of exception for each missing item. You could write a separate application that runs through the database and produces a report for any errors it finds.
|
|
|
|
|
thank you
It sounds a good way 
|
|
|
|
|
Need help to write Java program to Find and replace sTring in Docx and Doc files. I am getting "
Exception in thread "main" java.lang.NoSuchFieldError: RAW_XML_FILE_HEADER " error.
|
|
|
|
|
Without more information it is anyone's guess where that error occurs, and why. Please edit your question and explain exactly what your code is trying to do (you can show an extract of where the error occurs).
You should also check RAW_XML_FILE_HEADER - Google Search[^].
|
|
|
|
|
Hi everyone. I am new to Java and not even sure it can accomplish what I am trying to do. I have been asked to try to come up with a web based program that will create numbers in a sequential order....IE: 001, 002, 003.....upon every press of a button. I need these numbers to be able to be stored so that the next time someone else loads this up and presses the button, it will produce the next number in the sequence. It also has to work across many workstations and users. Is this even possible? Or should I look at another option? I thought Java might be the best option, seeing how easy it is to implement into HTML. Any help would be greatly appreciated.
|
|
|
|
|
Yes it is possible. You will need HTML and Javascript (not Java) for the front end. That will allow you to display the numbers and use a button for actions. Then you will need a suitable backend to save the last number created on the server. You could use Java, PHP or one of the .NET languages. Use Google to find samples of simple web applications in your language of choice.
|
|
|
|
|
Would javascript even be needed?
First display screen could be all html. Then button is just url request to load 'another' page which just returns the first (html) page with the new number.
Can't one do that in just html?
|
|
|
|
|
Quite possibly, but how would you increment the number?
|
|
|
|
|
The button causes another page to load. That new page has a button - with a different index.
|
|
|
|
|
Thanks for the suggestion.
|
|
|
|
|
Hi
Can my gif file be made use of to modify the same so that the elecopter.gif starts flying up
An applet java prg does this .(java applet program shown )How to modify my gif file
to function like the java prg or how to get the java plug for this.
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
<img src="Elecopter.gif" width="428" height="640" border="0">
</BODY>
</HTML>
modified 21-Nov-18 4:30am.
|
|
|
|
|
What happens when you try it?
|
|
|
|
|
Okay, I have scoured the internet for tutorials on writing Java on an Android.
So far, I think I would have a better chance of learning how by watching television commercials.
Okay, here's my goal; admittedly modest, but if the gang here can direct me, I'll be miles ahead from what the internet has to offer.
Spec: A Java App
Platform: Android phone
Function: None (It doesn't do anything)
All I want to do first is to write an Android app which...
- Just appears on the screen
- Doesn't accept any input
- Doesn't produce any (meaningful) output
- Doesn't interact with any other app in any meaningful way
- Goes away properly when you close it.
I intend to install the latest version of Android Studio on my desktop computer this week; Monday if possible, hopefully by Friday at the latest if my boss gives me a day or two off.
Okay, so, if I can properly install the current Android Studio; where is the first place I click ? What do I do ? I want to be able to move between computers, so I'll want the source files on a thumb drive.
Let's call this app: "DEADBEAT" Sound like a winner ?
What's my next step ?
|
|
|
|
|
|
Okay, I'll try that.
Thanks
(Voted your comment up one)
|
|
|
|