Multi-User Console Chat Program

Nov 22, 2014

My task is to create multiuser console chat program. During whole day of poking around , i finally stand on such concept:

1. When running , Server part must stay into while(true) loop and create threads on each ServerSocket.accept() call, providing socket object inside thread. i.e.

while (true){
System.out.println("Waiting for client to connect");
Thread t = new Thread(new Runner(servSocket.accept(),listOfClientSockets));
System.out.println("Starting thread");
t.start();
}

2. Client side always stays within while(true) loop and waiting for user input with ScannerInstance.nextLine() method.
As soon as user prints something and hits enter, data being captured from scanner and thrown to socket output stream to the server.

My question is : if all parties (X clients and server) are actually in waiting mode (server is waiting for connections and each client is waiting for user input), who will refresh the screen for each client to draw the messages other parties sent?

At this time , each party see updates only when he hits enter and while loop does next iteration reading data from buffer and displaying on console.

View Replies


ADVERTISEMENT

Java Chat Using MySQL / How To Keep Updating Chat

Nov 12, 2014

Using MySQL to store the chat data/users and then recieve the chat data every time the chat table updates because someone entered a new message. I am woundering if this is the right way to do it or should try something else?

What I am looking for is someway to run a query each time the database has been updated or receive data from the database each 10 sec, is it even posible, if yes then how? Been trying to look into threading, but do not seem solve this problem and cant find any information about it.

View Replies View Related

Encrypted Video Chat Program Using JMF

Oct 23, 2014

I am trying to make an encrypted video chat program using JMF. I have successfully written the "video chat" part - which includes getting data from webcam and transmitting it using RTP, but how to get raw data video to encrypt it before it stream between the webcam and the network.

For RTP I am using RTPManager, and for reading from the webcam I am using this code:

DataSource ds;
CaptureDeviceInfo di = null;
StateHelper sh = null;System.out.println("Started Video");
String str1 = "vfw:Logitech USB Video Camera:0";
String str2 = "vfw:Microsoft WDM Image Capture (Win32):0";
String str3 = "vfw:Microsoft WDM Image Capture (Win32):0 : vfw://0";

[Code] .....

I plan on using a stream cipher for encryption, maybe RC4.

View Replies View Related

Client / Server Chat Program

Dec 6, 2014

So i wrote this text to try and create a simple chat program that does the following: Prepend names to messages, announce entrance and exit of chat, display user list, and share a whiteboard.So far the Server seems to be working but the Chat Client is throwing errors at me left and right..

CURRENT ERROR:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:Windowssystem32>cd..
C:Windows>cd..
C:>Usersjaydesktopchat
'Usersjaydesktopchat' is not recognized as an internal or external command,
operable program or batch file.

[code]....

View Replies View Related

Simple Chat Program With Client / Server EOFException

Feb 13, 2015

When I Start Server and login from client everything goes fine but as soon as I want to send amessage or use showIn or even logOut .

Get below error

Exception creating new Input/output Streams: java.io.EOFException

View Replies View Related

Multi-word Hangman Game - Spaces Not Displayed When Program Run

Apr 9, 2015

I created a simple Hangman game. It functions correctly, the only issue is when the file contains a phrase (2 or more words), spaces are not displayed when the program is run. For example, if the phrase was Java Programming Forums.

It would appear as _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _.

I want there to be spaces in between the words. How could I fix this? What would I need to add to my code?

import java.util.Scanner;
import java.io.*;
 public class hangman{
public static void main (String[] args) throws FileNotFoundException{
Scanner kb = new Scanner(System.in);
String guess;
String guesses = "";
int wrongGuess = 8;

[Code] ....

View Replies View Related

Could Program Fail With Race Condition By Concurrent Threads In A Multi Thread Environment

Feb 18, 2014

I have a task of returning US holiday based on the given date and this utility will be used in a multi thread environment. I have written as below, how to know if my code breaks at any given point by multiple threads

Declared Enum

public enum Holiday {
CHRISTMASDAY("Christmas Day"),
GOODFRIDAY("Good Friday"),
INDEPENDENCEDAY("Independence Day"),
LABORDAY("Labor Day"),
NONE("None");

[code]...

I tried to test this with few concurrent threads, and noticed that the DB call is made for the very first time or when the year being requested is not same as the cached year. But I wanted to see, if this is properly synchronizing and would not fail in any case. My intention is to make a singleton HolidayCalendar, and also synchronized well enough so that every thread using this class gets the required data without blocking each other.

View Replies View Related

Using While Loop For Printing User Entered Name From Console

Jul 2, 2014

Ask user to enter a name alphabet by alphabet, and print d whole word as output,,,,,, use while loop?Since i am new to JAVA..i have no clue on how to begin?

View Replies View Related

Eclipse Java Program Console GUI?

Aug 15, 2014

im wanting to create a console gui that opens with my program game and people can type stuff in it to run commands as well as a debug option to show when errors happen and have a command to list all availble command.

View Replies View Related

How To Put Console On JFrame Or Graphics Program Window

Sep 8, 2014

how to put a console on a JFrame or on graphics window. I thought about simply using a JtextField however I don't have access to the readline command since it appears to me that it is only found in a Console Program. So basically I was wondering how to put up a console on JFrame so I can issue commands on it and watch graphical stuff happen on the same screen(minus where the console box is of course).

View Replies View Related

Basic Console Java Program - Generate Employee ID

Feb 27, 2014

Basic console java program. I need to generate an employee id. I have an employee class that I will paste here so you can see my fields and constructors.

public class Employee {
private String firstName;
private String lastName;
private int id;
public int nextUniqueId = 0;
public Scanner sc = new Scanner(System.in);

[Code] ....

View Replies View Related

Java App To Open A Console Base Program And Run A Command

Jan 13, 2015

I am struggling getting my java app to open a console window on either MacOS or windows and run a command. On windows I can get the cmd.exe program to open, but it won't execute the command. On MacOS, I cannot get it to even open the terminal.

String run = "c:
s34bil.exe
elap5.exe" + in + rst + out; //in, rst, out are parameters for the relpa5.exe file.
try {
Runtime rt = Runtime.getRuntime();
rt.exec(new String[]{"cmd.exe","/c",run,"start"});
} catch (IOException ex) {
Logger.getLogger(issrsUI.class.getName()).log(Level.SEVERE, null, ex);
}

View Replies View Related

Exporting A Java Program From Eclipse That Only Runs In Console

Oct 11, 2014

I have recently revisited a program I wrote a few years ago, that runs absolutely fine in the console in Eclipse. However, when I export it as a Runnable Jar File, then open the file on my Desktop, nothing happens.How do I get the program to export so that when I open the file, a window opens that acts as the console (so the program can run in it)?

View Replies View Related

Console Calculator Program - How To Split Array Of Strings

Apr 22, 2015

I'm writing a command line application of a calculator in Java. I need to be able to (as per program requirements) split the array of strings (6+3) into an array of strings? How would that be done? I know you can use the split method, but I am not really sure how that wold work to perform math with them?

On a side note: for this application, how could you make the program accept a variety of different lengths of strings to perform math with them?

View Replies View Related

Holiday Program - Using Jansi Library To Add Color To Console Text

Dec 26, 2014

While making my holiday program and trying to use the Jansi library to add color to the console text,

I got this output:

Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.RuntimeException: Uncompilable source code - package org.fusesource.jansi does not exist
at Main.<clinit>

View Replies View Related

Java Program That Will Ask A User To Input Grades Until User Inputs Sentinel Value

Apr 9, 2014

Write a java program that will ask a user to input grades until the user inputs the sentinel value -1. The program should test each input to determine whether 0<=grade<=100. If the grade entered is within this range, the program should print "Grade accepted;" if not, the program should print "Invalid input".

View Replies View Related

Program That Takes User Odd Number And Print Prime Numbers Lower Than User Input

Nov 4, 2014

I have been struggling with this program for weeks. This program is supposed to take a user's inputted odd number and then print out all prime numbers lower than that number.

public class PrimeNumber
{
Scanner scan = new Scanner(System.in);
int userNum;
String neg;

public void getUserNum()

[code]...

View Replies View Related

Small Chat Lobby

Feb 4, 2014

Me and my brother are working on a small java project to learn network programming and get some experience working with networking code. We decided to make a relatively simple client/server program where clients get into a simple chat lobby and can invite others to play small games(like pong). The basic server code has been written, and we have made a special client that is used for debugging.

We use a self-defined protocol of Strings where a message looks like "4-|user,pass". The number before the delimiter "-|" is the operation code, that tells the server what kind of message this client sends. Based on that number, the server dispatches the message to the appropriate handler method. 4 is authentication for example, and the handler looks the user and pass up in a file and if found, returns true, otherwise, false. Then the server responds to the clinet with 2-|"any message" where the client will recognize opcode 2 as a "authentication accepted" and proceed with the next part of client code. In a similar way, we plan to write all message types(both in the game, in the lobby and in a game setup room).

While testing we ran into a problem where the BufferedReader .readLine() does not seem to be a blocking call like it should be, so the client keeps spamming 'null' in the output field that we made to see the server response to the message we send. When we try to debug the server code and set breakpoints at the suspicious locations, it strangely skips both while(true) loops without activating either breakpoint and executes the finally{} code, even though the client did not close the connection and the second while loop was never entered. The first while loop IS entered though, because the test client gets a "0" on its output, which is the server message indicating "please authenticate yourself".

Also, if we approach things in a dumb way that can be done way more efficiently or easier to read/manage, please do tell. Keep in mind we are beginners though! We decided to use messages in a string format and decode it at both sides as it seemed easier than transmitting java objects and making sure they are of the same type, also for reducing overhead as much of possible. URL....

The server code:

package Chatroom;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.HashSet;

/**
* This is the main server class. It is the core of the server functionality, and the listener for incoming clients that will spawn threads to deal with clients, track their information, change their states and ultimately, clean up after all clients by keeping the data structures up to date.

[code]...

View Replies View Related

How To Create Chat Project

Jul 8, 2014

i don't know how create that project ,

View Replies View Related

Code For Multiuser Chat With GUI

Jun 19, 2014

i am writing the code for multiuser chat with GUI and i wanna create a quiz game where the all the users i.e the clients can aniticipate in the game. is there a way where we can combine the game and the users together in a single gui screen. the game is on the left box of the gui and chat space on the right.

View Replies View Related

Voice Chat Using Java MulticastSocket

Apr 13, 2014

I am trying to implement the voice chat using java multiCastSocket programming. Taking the input from the microphone and trying to listen it on the speaker. Problem is am not hear any voice back. I debugged through it wireshark and i am receiving the packets from the multicast group address. Looks like there is some problem while i am trying to get the sound out of speaker.

/*Sender Code*/
public class MulticastAudioSender {
/** Port to use for IP Multicast sending. */
public static final int IPM_PORT = 7778;
/** Address to use for IP Multicast sending. */
public static final String IPM_ADDRESS = "235.1.1.1";
 
[Code] ....

View Replies View Related

Using Socket And JSP For Web-based Chat Application

Feb 13, 2014

I am new to JSP !! and I'm developing a web-based chatting system using JSP and socket.

The problem I am facing is that the sender can send message but on the receiver side we have to manually refresh the page. The sender stays into blocking mode until the receiver refresh its page !

After that I've implemented auto-refresh on the receiver side and "Connection Refused" exception is generated.

View Replies View Related

Video Chat Tool Using Java RMI

Jul 3, 2014

I am stuck in making a C/S video chat program using JAVA RMI technology. I am more familiar with Java RMI.

View Replies View Related

Java Chat Application With Springs

Nov 28, 2014

how to develop a CHAT APPLICATION using Java springs .this should be very simple client server project with rich front end IT contains login page and a chat page.

View Replies View Related

Simple Server / Client Chat

Dec 28, 2014

I've been trying to create a server/client chat program, but I keep running into areas where I'm not really sure how to work it. I've run into a wall where my client just sits and spins instead of working. URL.... I can work out the dynamic parts later, I just want to understand the meat and potatoes of reading from sockets and writing to sockets (and how to do both at the same time).

View Replies View Related

Server / Multi Clients

Mar 9, 2014

I have made a server/multi Clients where Clients send Double data but my problem is that the clients send this data to Server only wonce, and the server waits again the connection from client. (I have to run the clients manually each time)what i'm looking: the client should always send data to server. like an infinite loop.

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved