• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

:( simple chat client n server..

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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..

megaupload
try compiling server.java, login.java, client.java
and running server.java n login.java
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
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
simranjit singh
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
java.lang.NullPointerException
at chat.Client.jButton1ActionPerformed(Client.java:131)
at chat.Client.access$000(Client.java:20)
at chat.Client$1.actionPerformed(Client.java:73)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6038)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
at java.awt.Component.processEvent(Component.java:5803)
at java.awt.Container.processEvent(Container.java:2058)
at java.awt.Component.dispatchEventImpl(Component.java:4410)
at java.awt.Container.dispatchEventImpl(Container.java:2116)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
at java.awt.Container.dispatchEventImpl(Container.java:2102)
at java.awt.Window.dispatchEventImpl(Window.java:2429)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
 
simranjit singh
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
According to the stack trace it's happening in Client.java 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.
 
simranjit singh
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 client.java, 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.

Henry
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic