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.
Any java file in a project can be run using "Run File" but when the file is run it will not accept command line parameters. For a project, the way to pass in command line arguments is to specify it in Run's Arguments under Project properties. The issue is that when you use Run File for any file that is not the main class of the project it will ignore the command line parameters. If you can use Run File on any Java file, we should have a mechanism to pass in command line arguments. This seems to be a very obvious requirement.
Makes sense. Not for NB 6.8 as the UI is already frozen, scheduled for next.
Understood. But, why would any Run File not read the arguments specified as part of the project's run settings? It seems like all the pieces are there but just that some wiring is missing.
The problem is when you have more main classes in one project. You will pass the global args to all main files started by run single. We can probably allow to specify args per file or at least when you start the class by run single and the class is also project main class the project args can be used.
Why not provide a united run/debug/profile dialog to customize the action detail...like eclipse...
*** Bug 194372 has been marked as a duplicate of this bug. ***
*** Bug 202745 has been marked as a duplicate of this bug. ***
I just managed to specify cmdline arguments pr class in NB7.0.1 using the following approach(I don't know where the magic happens, so bare with me): 1. I use maven (but again, I don't know if thats relevant). 2. I open the "Project Properties" dialog (right-click project -> Set Configuration -> Customize...). 3. I choose "Actions" in the Categories-tree (not "Run"). 4. From the list of Actions I choose "Run file via main()". I then get these values: Execute Goals: process-classes org.codehaus.mojo:exec-maven-plugin:1.2:exec Set Properties: exec.classpathScope=${classPathScope} exec.args=-classpath %classpath ${packageClassName} exec.executable=java 5. Now append to the exec.args line: ${cl.args.${className}} 6. Add a new line with the cmdline arguments for a class with main(): cl.args.MyClass=-One -Two -Three My "Set Properties:" field now looks like this: exec.classpathScope=${classPathScope} exec.args=-classpath %classpath ${packageClassName} ${cl.args.${className}} cl.args.MyClass=-One -Two -Three exec.executable=java 7. click OK 8. right-click MyClass.java -> Run File 9. observe that args={"-One", "-Two", "-Three"}
Has this even been looked at as something to enhance?
In fact the infrastructure already allows it. But there is no UI for it. The question is how the UI should look like. Should be there an action set cmd line args on file. Or should be the user forced to create an configuration like in eclipse which is complicated and not very user friendly.
For users switching from Eclipse (like me) this is a *huge* requirement. While I'm glad that someone found and documented the very round-about way of getting command line arguments passed in, this needs to be fixed in order to be competitive with Eclipse. A dialog similar to the "custom->goals..." for maven projects, with a "remember as" is all that's really needed.