Reputation: 171
How to display the NetBeans ide java program console output onto the windows command line output? please help as I am new to this...thanks in advance here I must execute the program from NetBeans but only the output must be displayed on my windows command line.
Upvotes: 2
Views: 4301
Reputation: 7018
I am not sure this can be done for an Ant project but it can be done for a Maven project.
Add something to wait for output before exiting or your terminal will exit without your having time to view the output.
public static void main(String[] args) {
System.out.println("hello");
try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
br.readLine();
} catch (Exception e) {
e.printStackTrace();
}
}
eg. From :
<properties>
<exec.args>-classpath %classpath wshackle.mavenproject2.Main</exec.args>
<exec.executable>java</exec.executable>
</properties>
to :
<properties>
<exec.args>-x java -classpath %classpath wshackle.mavenproject2.Main</exec.args>
<exec.executable>gnome-terminal</exec.executable>
</properties>
or for Windows:
<properties>
<exec.args>/c java -classpath %classpath wshackle.mavenproject2.Main</exec.args>
<exec.executable>cmd</exec.executable>
</properties>
Upvotes: 1