0

I have a small problem with the Mac terminal. I run a Java program from the terminal and try to read some stuff from the stdin using:

BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Produsul:" + System.getProperty("line.separator"));
productOrder.setProductName(in.readLine());

The program gets stuck. I think that somehow, it doesn't detect EOL. I tried setting Send string to shell (\033OF) for the end key, but this didn't solve the problem. What am I missing?

joanna
  • 743
  • 3
  • 13
  • 27
  • how have you set up the reader assigned to the variable `in`? – stevevls Nov 28 '12 at 22:44
  • Scanner in = new Scanner(System.in); – twodayslate Nov 28 '12 at 22:45
  • 1
    Scanner doesn't have a readLine() method, though. – John Kugelman Nov 28 '12 at 22:55
  • @stevevls: Yes, I did, you can see it now. I didn't initially post the whole piece of code, as it's very simple and works fine from Eclipse. I'm pretty sure the problem is the fact that I'm running my app from the terminal. Also, I need to run it this way, so I have to solve this. Any other ideas? – joanna Nov 29 '12 at 20:06
  • 1
    It's weird. I just tried it from my Mac and used your code (roughly) and it works fine. I'd say the problem is somewhere else in the surrounding code that you haven't shared. – mprivat Nov 29 '12 at 20:13
  • I don't think so, the program runs fine from Eclipse. From the terminal, the readLine() remains blocked. Are there any other keyboard settings which I'm missing? All the suggestions I found indicated the change for the end key, explained above, which doesn't solve my problem. – joanna Nov 29 '12 at 21:33

0 Answers0