1

Im trying to learn some Java, I am using Eclim and after following a tutorial I found that this does not work on Eclim + vim:

class variables{
    public static void main(String args[]){
        double number;
        number = 12.34;
        System.out.print(number);
    }
}

But when I do the same on Eclipse, it does work. The only way I can make it work on Eclim is by using

println

instead of

print

Any ideas on why this would happen??

edit:

Tried this:

class variables{
  public static void main(String args[]){
    double number;
    number = 12.34;
    System.out.flush();
    System.out.print(number);
  }
}

and still nothing. Again, it works on Eclipse, but not on Eclim

Mel Nicholson
  • 3,225
  • 14
  • 24
Rahatzi
  • 43
  • 5
  • 2
    I have [already answered that](http://stackoverflow.com/questions/17140928/java-eclim-vim-system-out-print-not-working?rq=1) – fge Jun 18 '13 at 06:14

2 Answers2

2

use .flush() after .print() because system.out is buffered stream... you'll have to flush the output before you use it.

In .println(), the output gets flushed automatically

Vaishali
  • 431
  • 1
  • 4
  • 17
  • I tried this and still no go: class variables{ public static void main(String args[]){ double number; number = 12.34; System.out.flush(); System.out.print(number); } } – Rahatzi Jun 18 '13 at 04:52
  • can u pls show the code which you tried – Vaishali Jun 18 '13 at 04:52
  • class variables{ public static void main(String args[]){ double number; number = 12.34; System.out.flush(); System.out.print(number); } } – Rahatzi Jun 18 '13 at 04:54
  • 1
    you have asked the same ques twice .. http://stackoverflow.com/questions/17140928/java-eclim-vim-system-out-print-not-working?rq=1 – Vaishali Jun 18 '13 at 04:57
  • 1
    @Monansh not only that but I gave the answer. Looks like OP didn't read the part when I say that you have to flush "_after_ you print, obviously"... – fge Jun 18 '13 at 06:15
  • @Monansh "flush AFTER print" not the other way as you wrote... – mschenk74 Jun 18 '13 at 07:05
  • sorry.. i have corrected it.. – Vaishali Jun 18 '13 at 08:14
  • @Monansh now I changed my downvote to an upvote (the downvote was not meant as an offense but only to mark the answer as wrong as long as it was not corrected) – mschenk74 Jun 18 '13 at 10:09
1

It is almost certain that it is indeed working, but you are confusing the output with your prompt, as lack of a newline is making the prompt that waits for your next command be in the same line as your printed result.

chamakits
  • 1,865
  • 1
  • 17
  • 26