I'm not sure if this can be done for the Ant project, but it can be done for the Maven project.
- Create a Maven Project. File β New Project. Select the Maven category and the Java Application project type. Click Next and then Finish to accept the project defaults.
- Add a main class with the public static void main (String args []) method. Expand the source packages in the Projects window. Choose any package. Right-click β New β βJava Classβ.
Add something to wait for the exit to exit or your terminal will exit without your 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(); } }
- Select a project in the project window. Right click for popup. Select "Properties." Select the Run category. Click the Browse button next to the main class and select Main Class.
- Run the project once in normal mode using the green triangle in the toolbar, the Run-> Run Project menu, or F6.
- In the project window, specify the "Project Files" node. Double-click "nbactions.xml".
- Change the properties for the run action. Change the executable to your terminal and add the appropriate arguments and java to the arguments.
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>
- Save and close this file.
- Run the project. Now it should be open in the external terminal.
source share