views:

111

answers:

2

Hi, I have strange problem with my Neatens+Maven installation. This is the shortest code to reproduce the problem:

public class App 
{
    public static void main( String[] args )
    {
           // Create a scanner to read from keyboard
    Scanner scanner = new Scanner (System.in);

   Scanner s= new Scanner(System.in);
    String param= s.next();
    System.out.println(param);
    }
}

When I'm running it as Maven Project inside Netbeans console seems to be broken. It just ignores my input. It's look like "infinitive loop" in String param= s.next(); (or like String param= s.next(); placed in infinitive loop)

However this project works fine when it's compiled as "Java Aplication" project. It also works O.K. if I build and run it from cmd.

System info: Os: Vista IDE: Netbeans 6.8 Maven: apache-maven-2.2.1

//edit

Built program (using mavean from Netbeans) works fine (I can run it from Windows cmd). I just can't test it (Run nor debug :() using Netbeans.

And I think I forgot to ask the question ;). So of course my first question is: how can I fix this problem?

And second is: Is it any workaround for this? For example configuring Netbeans to run external commend line app instead of using built in console.

//edit one more update:

I use Exec Maven Plugin version 1.1.1 Problem also occurs in NB 6.9 RC2. In both NB versions (6.8 and 6.9 RC2) I tested maven 3.0-beta-1 and maven-2.2.1 with the same result.

+1  A: 

I recall fixing some similar problem a while back, can't recall if it was before or after 6.8. The problem is two fold, there's input conversion within the maven build itself (as it's running the app in forked process/different jvm. then in netbeans console we again have to to the input piping again.

please check that you are using the latest released exec-maven-plugin. You can also reach the netbeans issuetracking for that problem, I'm sure you might get more context there.

mkleint
A: 

You can use the exec goal exec:java to run the app in the same vm (default is exec:exec - new vm).

skrolzik
Open project properties, select "Actions", in the listed actions select "Run Project" and change the "Execute Goals" from "org.codehaus.mojo:exec-maven-plugin:1.1.1:exec" to "org.codehaus.mojo:exec-maven-plugin:1.1.1:java"
skrolzik