This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 162416 - Cannot run command-line app in a maven project
Summary: Cannot run command-line app in a maven project
Status: RESOLVED DUPLICATE of bug 188864
Alias: None
Product: projects
Classification: Unclassified
Component: Maven (show other bugs)
Version: 6.x
Hardware: All Windows XP
: P3 blocker (vote)
Assignee: David Simonek
URL:
Keywords:
: 170229 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-04-10 16:13 UTC by Chris Kutler
Modified: 2010-08-05 13:39 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Kutler 2009-04-10 16:13:26 UTC
Below is a simple command line app. I made it as simple as possible to communicate my problem with running command line
apps in NetBeans if I use the Maven plugin.

If I create a regular Java project, put in this code, and run the project, the app works fine.

If I create a Maven project using the Maven plugin and NetBeans 6.5.1, and put in this code, the prompt does not appear
and my input does not get processed. Also, the only way to stop running the app is to shut NetBeans. Clicking the x
boxes does nothing.

What am I doing wrong?

package delme;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

 static String readln() {
   InputStreamReader inputStrReader = new InputStreamReader(System.in);
   BufferedReader buffRdr = new BufferedReader(inputStrReader);
   String str = null;
   try {
     str = buffRdr.readLine();
   } catch (IOException ioe) {
     System.err.println(ioe);
   }
   return str;
 }

 public static void main(String[] args) {
   while (true) {
     System.out.print("> ");
     String str = readln();
     String[] input = str.split("\\s");
     if (input[0].equals("exit") || input[0].equals("quit")) {
       System.exit(0);
     }
     System.out.println("You said " + str + " and length = " + input.length);
     for (int x = 0; x < input.length; x++) {
       System.out.println(input[x]);
     }
     for (int i = 0; i < input.length; i++) {
     }
   }
 }
}
Comment 1 Antonin Nebuzelsky 2009-04-10 16:54:50 UTC
Confirming in 6.7 dev.

Process output does not seem connected to the output window.
Comment 2 Milos Kleint 2009-04-14 09:10:56 UTC
the issue is most likely in the external project - exec-maven-plugin.
http://jira.codehaus.org/browse/MEXEC-25

While I'll try to create a patch for the exec plugin, it cannot be determined when the patch appears in a release
version of exec-maven-plugin. Thus setting milestone to "next".

Comment 3 Milos Kleint 2009-08-12 13:18:48 UTC
*** Issue 170229 has been marked as a duplicate of this issue. ***
Comment 4 Milos Kleint 2009-11-10 06:13:30 UTC
applied in mojo.codehaus.org svn repository. I've deployed a snapshot for testing at 
http://snapshots.repository.codehaus.org/org/codehaus/mojo/exec-maven-plugin/1.1.2-SNAPSHOT/

to use it, declare the s.r.c.org repository in settings.xml file and then change the action mapping in the IDE to 1.1.2-SNAPSHOT (instead of the current 1.1.1)
Comment 5 Antonin Nebuzelsky 2010-07-23 12:02:10 UTC
Fixed by exec-maven-plugin 1.2, see also issue 188864.
Comment 6 Antonin Nebuzelsky 2010-07-23 12:05:22 UTC
Verified in older build of NetBeans (which does not include fix of #188864) by changing Run Project action's Execute Goals property to use 1.2 in project's Properties/Actions which adds the following configuration to nbactions.xml in project's root

<?xml version="1.0" encoding="UTF-8"?>
<actions>
        <action>
            <actionName>run</actionName>
            <goals>
                <goal>process-classes</goal>
                <goal>org.codehaus.mojo:exec-maven-plugin:1.2:exec</goal>
            </goals>
            <properties>
                <exec.classpathScope>runtime</exec.classpathScope>
                <exec.args>-classpath %classpath ${packageClassName}</exec.args>
                <exec.executable>java</exec.executable>
            </properties>
        </action>
    </actions>
Comment 7 Antonin Nebuzelsky 2010-07-23 12:19:02 UTC
Verified also with a new project created with the latest dev build which contains the fix of #188864. By default version 1.2 of exec-maven-plugin is used and the process output/input is correctly bound to Output window.
Comment 8 Jesse Glick 2010-08-05 13:39:54 UTC

*** This bug has been marked as a duplicate of bug 188864 ***