The moose likes Java in General and the fly likes :(  simple chat client n server.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark ":(  simple chat client n server.." Watch ":(  simple chat client n server.." New topic

:( simple chat client n server..

simranjit singh

Joined: Mar 01, 2007
Posts: 12
i am developing a code from headfirst java book from orielly on netbeans..

since d code is huge i cannot type it or copy it here.. so i hv uploaded it on d site..

try compiling,,
and running n
d problem i am having is when i try sending message from client d printwriter or my textfiled gives a nullpointer exception.. i hv tried a lot debugging to find wat might b probling but cannot find it..
i will b glad if somebody spends his/her time telling wat d prob is.. i m kinda newbie for java..

netbeans m using is 5.5 n jdk1.6
Deepak Bala

Joined: Feb 24, 2006
Posts: 6662

What is "b" "d" "m" "n" "wat" ? Please use real words. Also please post your stack trace and give us a better high level overview of your problem to receive better responses

SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15084

Where do you see the NullPointerException? Look carefully at the error message and the stack trace. It will tell you exactly in which line of code in which source file the exception happens.

Lookup that line in your source code. Something there is null when it shouldn't be. Find out why that is so and solve the problem.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
simranjit singh

Joined: Mar 01, 2007
Posts: 12
at chat.Client.jButton1ActionPerformed(
at chat.Client.access$000(
at chat.Client$1.actionPerformed(
at javax.swing.AbstractButton.fireActionPerformed(
at javax.swing.AbstractButton$Handler.actionPerformed(
at javax.swing.DefaultButtonModel.fireActionPerformed(
at javax.swing.DefaultButtonModel.setPressed(
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(
at java.awt.Component.processMouseEvent(
at javax.swing.JComponent.processMouseEvent(
at java.awt.Component.processEvent(
at java.awt.Container.processEvent(
at java.awt.Component.dispatchEventImpl(
at java.awt.Container.dispatchEventImpl(
at java.awt.Component.dispatchEvent(
at java.awt.LightweightDispatcher.retargetMouseEvent(
at java.awt.LightweightDispatcher.processMouseEvent(
at java.awt.LightweightDispatcher.dispatchEvent(
at java.awt.Container.dispatchEventImpl(
at java.awt.Window.dispatchEventImpl(
at java.awt.Component.dispatchEvent(
at java.awt.EventQueue.dispatchEvent(
at java.awt.EventDispatchThread.pumpOneEventForFilters(
at java.awt.EventDispatchThread.pumpEventsForFilter(
at java.awt.EventDispatchThread.pumpEventsForHierarchy(
at java.awt.EventDispatchThread.pumpEvents(
at java.awt.EventDispatchThread.pumpEvents(
simranjit singh

Joined: Mar 01, 2007
Posts: 12
this above is the stack trace as requested..
the problem is the code for the jtextfield is all self generated by netbeans ide and i am not able to find out why it is showing me nullpointer
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

According to the stack trace it's happening in at line 131. Something on the left hand side of a dot or a "[" is null. Whatever fits this description on this line must be null, so find out why it is.

[Jess in Action][AskingGoodQuestions]
simranjit singh

Joined: Mar 01, 2007
Posts: 12
this i also know..
if i wz able to find the error, why wud i post it here..
i dont know why is it giving error, according to me code is fine..

[ March 02, 2007: Message edited by: simranjit singh ]

[Andrew: removed swearing.]
[ March 02, 2007: Message edited by: Andrew Monkhouse ]
Henry Wong

Joined: Sep 28, 2004
Posts: 20525

Originally posted by simranjit singh:
this i also know..
if i wz able to find the error, why wud i post it here..
i dont know why is it giving error, according to me code is fine..

What do you mean by "according to me code is fine"? What did you look at?

Bring up netbeans, load up, and go to line 131. At this point, either...

(1) bring up the netbeans debugger, place a breakpoint just before line 131. run it to the breakpoint. and trace it til you get the exception. or...

(2) place a System.out.print() just before and after where the error is happening, printing out variables being used. After a couple of runs, you should be able to isolate the exact line and variable causing it.

Don't assume that you found the error... if you don't know why it is happening, you haven't found the error.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11955

according to me code is fine

Well, if according to YOU it's fine, then why are we having this discussion?

OH, that's right. Because your code is NOT fine. That is what the exception is telling you.

if i wz able to find the error, why wud i post it here..

I'm not sure what all these terms mean... "wz" is not a word, nor is "wud". But if you mean what i THINK you mean, the answer is to get help. To learn. to get guidance.

If you think we are here to do you work for you, you are wrong. We try and teach people how to solve their problems, and how to think about things.

Both Henry and Ernest have give you suggestions on where to start. Follow their advice, and if you get stuck, come back with what you have found, and ask a new question.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
I agree. Here's the link:
subject: :( simple chat client n server..
It's not a secret anymore!