problem running java program.


I've just got JBuilder 3 and tried to run my .java program. It run detected no errors. but the result didn't display. I've messed about with it but just wont display. I then created a program to display a message to the screen:

System.out.println("WORK DAM YOU");

but it didn't work....

I then tried stepping into the program.. and it did display the message but once i came out of the program the display window closed...

I think i need a kinder C++ command like GetChar() but in java..

Anyone any ideas?

Thanks
*Ribbleton_

Comments

  • Post your code and someone could probably give a specific answer.

    :
    : I've just got JBuilder 3 and tried to run my .java program. It run detected no errors. but the result didn't display. I've messed about with it but just wont display. I then created a program to display a message to the screen:
    :
    : System.out.println("WORK DAM YOU");
    :
    : but it didn't work....
    :
    : I then tried stepping into the program.. and it did display the message but once i came out of the program the display window closed...
    :
    : I think i need a kinder C++ command like GetChar() but in java..
    :
    : Anyone any ideas?
    :
    : Thanks
    : *Ribbleton_
    :

  • :
    : I've just got JBuilder 3 and tried to run my .java program. It run detected no errors...
    : ...
    : I think i need a kinder C++ command like GetChar() but in java..
    :
    : Anyone any ideas?
    :
    : Thanks
    : *Ribbleton_


    Hi,
    Are you sure you ran you program or did you just compile it. Sorry I don't use JBuilder so I don't really know it. Perhaps it ran but JBuilder does not show a console window?!
    Anyways here's some small code for you that should work:
    [code]
    import java.io.IOException;

    public class Kinder {
    //specifies the niceness of our tiny program
    private static final boolean DEBUG = true;

    //reads from stdin until user
    //presses 'return'
    public static String readStdIn() {
    try {
    int i = System.in.read();
    byte[] buffer = new byte[System.in.available()+1];
    buffer[0] = (byte)i;
    System.in.read(buffer,1,buffer.length-2);
    return new String(buffer);

    } catch (IOException ioe) {
    if (DEBUG) {
    System.err.println("ERROR READING FROM STDIN");
    ioe.printStackTrace();
    }
    }
    return null;
    }

    //starts the application
    public static void main(String[] args) {
    System.out.print("How are you? ");
    String answer= readStdIn().toLowerCase().trim();
    if (answer.equals("fine")) {
    System.out.println("
    Thats nice :)");
    } else if (answer.equals("bad")) {
    System.out.println("
    Relax and have some tea");
    } else {
    System.out.println("
    Uhhh Ohhh ?!");
    }
    }
    }
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories