0

I am trying to write a simple java application using console input as GUI.

Below can the main method be seen: public static void main(String[] args) {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    String input = "";

    while (input.compareToIgnoreCase("Exit")!= 0) {
        System.out.print("Enter something:");
        try {
            input = br.readLine();

            String[] arguments =  input.split("\\s+");

            parse(arguments);

        } catch (IOException ex) {
            Logger.getLogger(CB1TestApplication.class.getName()).log(Level.SEVERE, null, ex);
        }
    }         
}

My problem is that running this on a Raspberry Pi (final target) "input = br.readLine();" don't seems to work.

The purpose of the application is to manipulate GPIO by giving appropriate commands. Not being able to debug on the Raspberry Pi,, makes the development tedious.

Using Netbeans and Java.

Can anyone help ?

//lg

lg.lindstrom
  • 776
  • 1
  • 13
  • 31
  • Ok, so first question, when you say "doesn't work", what is the exact outcome? Like, does it just skip the whole thing or does it block at the input and you never get past it? – CodeChimp Sep 27 '16 at 17:36
  • The output window in Netbeans where the "Enter something" text is shown, neither echos the characters from the keyboard neither it seems like the program get past the "br.redline()". – lg.lindstrom Sep 28 '16 at 06:59
  • Can you try running from Command Line? I don't use Netbeans, so can't speak to whether or not it allows STDIN from the IDE like that. – CodeChimp Sep 29 '16 at 13:26
  • If I log into Raspberry with ssh, and execute cd '/home/pi/NetBeansProjects//CommandLine'; '/home/pi/jre//bin/java' -Dfile.encoding=UTF-8 -jar /home/pi/NetBeansProjects//CommandLine/dist/CommandLine.jar the program works fine. The command above is the same command that Netbeans sends to Raspberry, when starting a remote debug session. – lg.lindstrom Oct 02 '16 at 18:14
  • So, what that tells me is that Netbeans most likely does not allow STDIN from it's debugger. One solution would be to run it using remove debugging, called [jdwp](http://stackoverflow.com/questions/975271/remote-debugging-a-java-application), which would allow you to remotely attach the Netbeans debugger to the rPI process (or, to a process running locally but not in Netbeans directly). You can even specify a flag with jdwp to tell it to break when the app starts so you can get your remote debugger attached from the start or the program. – CodeChimp Oct 03 '16 at 13:41
  • Remote debugging in Netbeans are using jdwp,, or are am mistaking here? The idea behind setting up remote debugging in Netbeans IDE is to enable the use of jdwp in a easy manner. – lg.lindstrom Oct 03 '16 at 18:18
  • Again, not a Netbeans user, but almost all Java-based IDEs do NOT use jdwp by default when you just hit the "run" or "debug" button. They usually run the app by default as a process of the IDE. This is for speed purposes, as jdwp is not known to be performant (although it's gotten a lot better since it was introduced). Most IDEs call jdwp "remote debugging", and usually involve quite a few additional steps to get working. I suggested using remote debugging since the STDIN doesn't appear to work when debugging directly in Netbeans. – CodeChimp Oct 04 '16 at 12:28

0 Answers0