• Post Reply Bookmark Topic Watch Topic
  • New Topic

Head First Java book, chapter 15 - help needed with running the chat terminals  RSS feed

 
niilo joli
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

First, thanks for authoring this wonderful resource. Please, I need your help to clarify something in the book.

Problem:
I am having trouble understanding how to run two chat client terminals and the server application.

Reference:
The instructions on page 520 in chapter 15 read, "To run the chat client, you need two terminals. First, launch this server from one terminal, then launch the client from another terminal." (520)

Programming IDE:
Eclipse version 3.3.0 ( http://www.eclipse.org/platform )

Other related questions:
Q1: When the author wrote that I will need to run two terminals, does this mean that I should run a terminal emulation software like PuTTy (http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html ) on each WinXP machine ( terminal ) from which a user will send messages?

Q2: Should a copy of the files that were generated in Eclipse when the package (includes my .java files) was compiled be placed on each of the terminals?

Q3: Will I need to install Eclipse on each of the terminals to run the client chat application on them? Things I've tried:
I have tried running PuTTy on the client PC by specifying localhost - no luck.

* I'm really not sure how to coordinate all this. Please help! *
[ November 24, 2007: Message edited by: Heathcliff ]
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your application requires users to connect remotely, you will need to specify a port as well as a location. 'localhost' on its own is not enough.

1) see above
2) No, the clients will talk to your application using a standard protocol. Think of it like hosting a web application: the clients use a browser, they don't need your application running locally
3) no, see 2)
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not familiar with the book, so I'll take a stab purely based on what you wrote.
Q1: When the author wrote that I will need to run two terminals, does this mean that I should run a terminal emulation software like PuTTy (http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html ) on each WinXP machine ( terminal ) from which a user will send messages?

I think "terminal" here means a DOS/Console window, not a special terminal software.

Q2: Should a copy of the files that were generated in Eclipse when the package (includes my .java files) was compiled be placed on each of the terminals?

The client will need the .class (not .java) files that get created. Not the ones making up the server, just the ones making up the client.

Q3: Will I need to install Eclipse on each of the terminals to run the client chat application on them? [/list] Things I've tried:
I have tried running PuTTy on the client PC by specifying localhost - no luck.

Eclipse is not needed, and neither is Putty (at least not from the way I read the problem description).

By the way, your display name is still not OK. It needs to have a first and a last name.
[ November 24, 2007: Message edited by: Ulf Dittmer ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66307
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Heathcliff", please read David's message again. Your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.
 
niilo joli
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by David O'Meara:
If your application requires users to connect remotely, you will need to specify a port as well as a location. 'localhost' on its own is not enough.

1) see above
2) No, the clients will talk to your application using a standard protocol. Think of it like hosting a web application: the clients use a browser, they don't need your application running locally
3) no, see 2)


Thanks for your reply. My IP address and the open port are correctly specified in the client code. However, it sounds like remote users will just need to open I.E. or Firefox, then type: the server IP address with the port to reach the chat server. This does not work. Would you mind being more precise, please?
[ November 25, 2007: Message edited by: niilo joli ]
 
niilo joli
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulf Dittmer:
I'm not familiar with the book, so I'll take a stab purely based on what you wrote.

Eclipse is not needed, and neither is Putty (at least not from the way I read the problem description).

By the way, your display name is still not OK. It needs to have a first and a last name.

[ November 24, 2007: Message edited by: Ulf Dittmer ]


Thanks for your reply.

I've tried opening an MS DOS console and launching the client.class from there, but a dialogue box appears asking where I'd like to save the file. Do you know the command line that should be specified to run the client.class from an MS DOS prompt?

Again, I am trying to understand how to access the chat server that I am running in Eclipse from another machine on my network - a machine that I have copied the client.class code in which the correct IP address and port number to the server are provided.
[ November 25, 2007: Message edited by: niilo joli ]
 
Tarek Khojah
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You just need to have two different "processes" running of the same client program.
Compile the client code, then open two different command prompt windows and run the client code in each, that's almost as if you're connecting from two different remote computers to the server.
 
niilo joli
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The chat application is composed of two files: 1 server, 1 client

Using the Eclipse IDE:
1. I start eclipse and run the chat server code.
2. Then, I run the client code ( a chat client window appears; I can see that the server is logging the messages if I click the console tab of the Eclipse interface; however, I do not see anything displayed in the window of the chat client )
From an MS DOS console:
I navigate to the directory where my .java files are and compile them successfully with "javac". Note: When I try to run them using "java", I get this: "chat client>java ChatClient
Exception in thread "main" java.lang.NoClassDefFoundError: ChatClient (wrong nam
e: mike_woods_chat_logiciel/ChatClient)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)

[ November 26, 2007: Message edited by: niilo joli ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!