Skip to content

The project > Properties > Run panel, Arguments field values are ignored #3853

Open

Description

@lburaggi

Apache NetBeans version

Apache NetBeans 13

What happened

The values set in the Project properties panel, Run section, Arguments field are ignored and not passed to the main(args) call.

How to reproduce

  1. Create a new Java Application Project (both the Ant or Maven based projects show the same problem)
  2. Modify the main class template as shown:
public static void main(String[] args) {
	System.out.println("Size: " + args.length);
}
  1. Open the Project Properties panel, go to the Run panel and write some arguments in the Arguments field
    Immagine 2022-03-25 014728

  2. Run the program and note the result:
    Immagine 2022-03-25 015034

The args String[] is empty !

Did this work correctly in an earlier version?

Apache NetBeans 12.3 or earlier

Operating System

Windows 10

JDK

Java 17.0.2

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else

The bug is very easy to reproduce on my PC, I hope you will reproduce it too

Are you willing to submit a pull request?

No

Code of Conduct

Yes

Activity

  1. added
    kind:bug
    needs:triage
    on Mar 25, 2022
  2. sdedic commented on Mar 26, 2022

    @sdedic
    Member

    Hi - just tried that with NB13 - though I am printing System.err.println(Arrays.asList(args));, it works as expected. Tried with Java/maven application JDK11, and Java/ant application JDK17.
    Could you please zip & attach your sample project sources ? There can be something screwed up with the settings.

    Could you describe exactly the project creation steps (I must have done something differently as my projects were workign OK) ?

  3. lburaggi commented on Mar 28, 2022

    @lburaggi
    Author

    That's very strange !
    I repeated all the process on a different Windows PC:

    1. OS is Windows 10 PRO version 21H2 build 19044.1586
    2. Java version "17.0.2" 2022-01-18 LTS
    3. Netbeans About Panel reports:
      Product Version: Apache NetBeans IDE 13
      Java: 17.0.2; Java HotSpot(TM) 64-Bit Server VM 17.0.2+8-LTS-86
      Runtime: Java(TM) SE Runtime Environment 17.0.2+8-LTS-86
      System: Windows 10 version 10.0 running on amd64; Cp1252; it_IT (nb)

    The Netbeans on the PC is a fresh installation of version 13 (Note: when requested I answered yes to the question: Do you want to import the previous NetBeans environment)
    Detailed project creation step list:

    1. New Project button selected
    2. In the New Project panel I selected the "Java with Maven" category and "Java Application" project
    3. The project name is "p", all other parameters left unchanged
    4. I edited the P class as follow:
    
    package it.horsa.devlab.p;
    
    import java.util.Arrays;
    
    /**
     *
     * @author Luca Buraggi
     */
    public class P {
    
        public static void main(String[] args) {
            System.out.println("Size: " + args.length);
    	System.err.println(Arrays.asList(args));
        }
    }
    
    1. In the project Properties Panel, Run category, I set the Arguments field = a0 a1 a2
    2. I run the project with the following result:
    cd C:\Users\luca\Documents\NetBeansProjects\p; "JAVA_HOME=C:\\Program Files\\Java\\jdk-17.0.2" M2_HOME=C:\\bin\\maven cmd /c "\"C:\\bin\\maven\\bin\\mvn.cmd\" -Dexec.vmArgs= \"-Dexec.args=${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs}\" \"-Dexec.executable=C:\\Program Files\\Java\\jdk-17.0.2\\bin\\java.exe\" -Dexec.mainClass=it.horsa.devlab.p.P -Dexec.classpathScope=runtime -Dexec.appArgs= \"-Dmaven.ext.class.path=C:\\Program Files\\NetBeans-13\\netbeans\\java\\maven-nblib\\netbeans-eventspy.jar\" -Dfile.encoding=UTF-8 process-classes org.codehaus.mojo:exec-maven-plugin:3.0.0:exec"
    Scanning for projects...
    Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/mojo/exec-maven-plugin/3.0.0/exec-maven-plugin-3.0.0.pom
    Progress (1): 2.7/14 kB
    Progress (1): 5.5/14 kB
    Progress (1): 8.2/14 kB
    Progress (1): 11/14 kB 
    Progress (1): 14 kB   
                       
    Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/mojo/exec-maven-plugin/3.0.0/exec-maven-plugin-3.0.0.pom (14 kB at 28 kB/s)
    Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/mojo/mojo-parent/50/mojo-parent-50.pom
    Progress (1): 2.7/34 kB
    Progress (1): 5.5/34 kB
    Progress (1): 8.2/34 kB
    Progress (1): 11/34 kB 
    Progress (1): 14/34 kB
    Progress (1): 16/34 kB
    Progress (1): 19/34 kB
    Progress (1): 21/34 kB
    Progress (1): 24/34 kB
    Progress (1): 27/34 kB
    Progress (1): 30/34 kB
    Progress (1): 32/34 kB
    Progress (1): 34 kB   
                       
    Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/mojo/mojo-parent/50/mojo-parent-50.pom (34 kB at 656 kB/s)
    
    -------------------------< it.horsa.devlab:p >--------------------------
    Building p 1.0-SNAPSHOT
    --------------------------------[ jar ]---------------------------------
    
    --- maven-resources-plugin:2.6:resources (default-resources) @ p ---
    Using 'UTF-8' encoding to copy filtered resources.
    skip non existing resourceDirectory C:\Users\luca\Documents\NetBeansProjects\p\src\main\resources
    
    --- maven-compiler-plugin:3.1:compile (default-compile) @ p ---
    Changes detected - recompiling the module!
    Compiling 1 source file to C:\Users\luca\Documents\NetBeansProjects\p\target\classes
    
    --- exec-maven-plugin:3.0.0:exec (default-cli) @ p ---
    Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-artifact-transfer/0.10.1/maven-artifact-transfer-0.10.1.pom
    Progress (1): 2.7/11 kB
    Progress (1): 5.5/11 kB
    Progress (1): 7.9/11 kB
    Progress (1): 11/11 kB 
    Progress (1): 11 kB   
                       
    Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-artifact-transfer/0.10.1/maven-artifact-transfer-0.10.1.pom (11 kB at 239 kB/s)
    Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-artifact-transfer/0.10.1/maven-artifact-transfer-0.10.1.jar
    Progress (1): 4.1/128 kB
    Progress (1): 8.2/128 kB
    Progress (1): 12/128 kB 
    Progress (1): 16/128 kB
    Progress (1): 20/128 kB
    Progress (1): 24/128 kB
    Progress (1): 28/128 kB
    Progress (1): 32/128 kB
    Progress (1): 36/128 kB
    Progress (1): 40/128 kB
    Progress (1): 45/128 kB
    Progress (1): 49/128 kB
    Progress (1): 53/128 kB
    Progress (1): 57/128 kB
    Progress (1): 61/128 kB
    Progress (1): 65/128 kB
    Progress (1): 69/128 kB
    Progress (1): 73/128 kB
    Progress (1): 77/128 kB
    Progress (1): 81/128 kB
    Progress (1): 85/128 kB
    Progress (1): 90/128 kB
    Progress (1): 94/128 kB
    Progress (1): 98/128 kB
    Progress (1): 102/128 kB
    Progress (1): 106/128 kB
    Progress (1): 110/128 kB
    Progress (1): 114/128 kB
    Progress (1): 118/128 kB
    Progress (1): 122/128 kB
    Progress (1): 126/128 kB
    Progress (1): 128 kB    
                        
    Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-artifact-transfer/0.10.1/maven-artifact-transfer-0.10.1.jar (128 kB at 1.9 MB/s)
    Size: 0
    []
    ------------------------------------------------------------------------
    BUILD SUCCESS
    ------------------------------------------------------------------------
    Total time:  4.735 s
    Finished at: 2022-03-28T16:01:51+02:00
    ------------------------------------------------------------------------
    

    As you can see the result is the same even if this is a different PC and a fresh installation
    Do you think that my configuration could be screwed up when importing the previous Netbeans version environment during installation ?

    This is my IDE log, showing some strange errors I can't explain.
    IDE.log.txt

  4. lburaggi commented on Mar 28, 2022

    @lburaggi
    Author

    Looking at the IDE log I noticed that it seems there is something wrong in the file nbactions.xml. So I attach the file here:
    nbactions.xml.txt

  5. lburaggi commented on Mar 28, 2022

    @lburaggi
    Author

    I also executed this test:

    1. I closed the project and Netbeans
    2. Deleted the file nbactions.xml
    3. Restarted Netbeans and reopened the project. Checking the ide log did not show any error message
    4. In the project Properties panel, Run category I re-added the a0 a1 a2 arguments
    5. Checking the ide log showed many error messages about nbactions.txt
    6. The run result was the same
  6. sdedic commented on Mar 28, 2022

    @sdedic
    Member

    IDE.log is here - good ! Could you also please zip & attach the faulty sample project, just in case ?

  7. lburaggi commented on Mar 28, 2022

    @lburaggi
    Author

    p.zip
    Here is the project

  8. added
    Java
    on May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Javakind:bugneeds:triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions