Your Ad Here Your Ad Here
Results 1 to 3 of 3

Thread: need help from a java programmer

  1. #1
    99shassan's Avatar Poster BT Rep: +1
    Join Date
    Jul 2003
    Posts
    830
    I have a gui and I did something to it last night, and now it won't send numbers to a server.

    I have 6 text boxes, I save the number in those boxes in an array. Then set up a loop that sends each number to an already connected client. However, when I get to the last number, the server keeps stopping and giving me this error:

    java.lang.ArrayIndexOutOfBoundsException: -3
    at JavaServer.lottery(JavaServer.java:215)
    at JavaServer.main(JavaServer.java:249)
    java.lang.NullPointerException
    at JavaServer.main(JavaServer.java:255)



    I have no idea why. since both arrays are 6.

    using scanner as input on both client and server
    server

    input
    Code:
    scanner  ClientIn = new Scanner
                     (connection.getInputStream());
    
    output: 
     Prin***iter Output = new Prin***iter(connection.getOutputStream(), true);
    client
    Code:
       Scanner input = new Scanner(clconn.getInputStream());
                
                //output so client can send to server
                         Prin***iter output = new Prin***iter
                         (clconn.getOutputStream(),true);
    and on my client, the error message i get is

    Code:
     
    
    java.util.NoSuchElementException: No line found
            at java.util.Scanner.nextLine(Scanner.java:1516)
            at Main.SendNumberstoServerButtonActionPerformed(Main.java:863)
            at Main.access$500(Main.java:17)
            at Main$6.actionPerformed(Main.java:231)
            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:6041)
            at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
            at java.awt.Component.processEvent(Component.java:5806)
            at java.awt.Container.processEvent(Container.java:2058)
            at java.awt.Component.dispatchEventImpl(Component.java:4413)
            at java.awt.Container.dispatchEventImpl(Container.java:2116)
            at java.awt.Component.dispatchEvent(Component.java:4243)
            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:2440)
            at java.awt.Component.dispatchEvent(Component.java:4243)
            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)
    where I think its referring to is here:

    server
    Code:
    if (status==1){
                         Thread.sleep(900);
                         System.out.println("waitfail");
                         ServerOutput.println("NO");
                     }
                     else {
                         Thread.sleep(900);
                         System.out.println("waitpass");
                         ServerOutput.println("OK");
                         index=2;
                     }
    client
    Code:
     
            status = input.nextLine();
    On further inspection, it seems that the server receives the 6 numbers just fine (I have a println command to print out the numbers it receives, which it does. But when it gets to that point, that happens.
    Last edited by 99shassan; 04-04-2008 at 10:37 AM.
    Changed SPAN settings in sig a YEAR after it was removed

  2. Internet, Programming and Graphics   -   #2
    99shassan's Avatar Poster BT Rep: +1
    Join Date
    Jul 2003
    Posts
    830
    solved it, I declared a socket twice
    Changed SPAN settings in sig a YEAR after it was removed

  3. Internet, Programming and Graphics   -   #3
    BANNED BT Rep: +100BT Rep +100BT Rep +100BT Rep +100BT Rep +100BT Rep +100BT Rep +100BT Rep +100BT Rep +100BT Rep +100BT Rep +100BT Rep +100BT Rep +100BT Rep +100BT Rep +100BT Rep +100BT Rep +100BT Rep +100BT Rep +100BT Rep +100
    Join Date
    Jul 2007
    Location
    Web 5.1
    Age
    78
    Posts
    2,108
    u sux lolz

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •