3

It's not a weird program. It's a simple C++ Hello World program, and for whatever reason there is no output to the terminal either in the terminal or in the output window. Here's my "code".

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char** argv) {
    cout << "Hello there peeps!";
    cout << endl;
    system("pause");
    return 0;
}

Using Netbeans 6.9 on Ubuntu 11.04 Natty

avatarmonkeykirby
  • 339
  • 1
  • 3
  • 11
  • Does building the code show any errors? – arunkumar Sep 01 '11 at 16:49
  • Is it being compiled in 64-bit? I remember there being a bug a while back with 64 bit compiled programs and output in Netbeans. – Jesus Ramos Sep 01 '11 at 16:52
  • I didn't think of that. The version of Linux is x86, let me see if I'm compiling the wrong output. – avatarmonkeykirby Sep 01 '11 at 16:54
  • It looks like it's compiling in x86. The program will run even, but still no output. – avatarmonkeykirby Sep 01 '11 at 16:55
  • I'm not sure is this a cause of your problem but in Linux there is no command "pause" as in DOS/Windows. Also you better avoid such C++ code which waits for input from user by calling some OS specific commands like "pause", because it is not portable. Instead you can pause a program in C++ by reading an keyboard input until enter is hit => `cin.get()`. And if you **really really** want to read ANY single keystroke in Linux - you can [look here](http://www.doctort.org/adam/nerd-notes/reading-single-keystroke-on-linux.html). – Agnius Vasiliauskas Sep 01 '11 at 20:52
  • According to what @0x69 said [here](http://www.gidnetwork.com/b-61.html) is more info why you **shouldn't** use `system("pause");` in any of your programs, not only linux versions. – Theocharis K. Jan 18 '13 at 05:18

2 Answers2

2

You may try this:

Project properties -> Run -> Console Type and select Standard Output there.

If this is already selected test with Internal Terminal.

ollo
  • 24,797
  • 14
  • 106
  • 155
  • 1
    Had this problem on Lubuntu 14.04 with NetBeans 8.0.2 and JRE 1.7.0_75, OpenJDK. Your suggestion fixed it, thanks! Could you possibly elaborate what's different between the two? I wasn't even aware of this feature, I assumed NetBeans was already using stdout. – Nobilis Mar 05 '15 at 21:37
  • 1
    I assume the internal terminal is some (java / netbeans ?) implemented version that does not flush correctly. Usually as another workaround: run with debugger - this works often too. So i guess the internal terminal uses the error stream in debug mode (auto-flushed) and out stream if running normal (not correctly flushed?). Maybe the *standard output* uses stdout / stderr directly instead or runs as a native process and displays it's output. But this is all only a speculation. – ollo Mar 06 '15 at 14:08
  • I wonder if it's also to do with using threads, as I was compiling a program in C++ that uses threads which was already running in debug mode. Before that I hadn't noticed any problems. I wonder why they had to use an internal terminal and couldn't just reuse `stdout`. – Nobilis Mar 06 '15 at 15:06
  • 1
    Probably this comes from the cross-platform requirements. Remember: Netbeans has to run on very different systems. Possibly it's an issue not for all operating systems (but i don't know for sure). – ollo Mar 06 '15 at 15:24
  • This is not a solution, it's a workaround. If Netbeans is not creating an external terminal, it means there is a configuration problem with the computer system as a whole. – DragonLord Aug 20 '16 at 02:43
  • Note Lubuntu does not come out of the box with **xterm** installed. See next answer. – DragonLord Aug 20 '16 at 03:15
1

Try installing xterm, that worked for me. (On fedora 18, but Ubuntu should be similar)

sudo apt-get install xterm

or

sudo yum install xterm
Ramo
  • 283
  • 1
  • 5
  • 15
  • Correct answer. Note also it's currently necessary to **restart Netbeans** in order for this to take effect. – DragonLord Aug 20 '16 at 03:11