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 170356 - Project-Run-Arguments doe not work
Summary: Project-Run-Arguments doe not work
Status: RESOLVED DUPLICATE of bug 68099
Alias: None
Product: ide
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: PC All
: P3 blocker (vote)
Assignee: issues@ide
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-08-14 09:52 UTC by dizzzz
Modified: 2009-08-17 17:59 UTC (History)
1 user (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 dizzzz 2009-08-14 09:52:12 UTC
I have created a few projects now, I discovered that the Run-Arguments data are not passed to the args[] parameter of
the generated main function.

An array of strings is indeed passed as argument but it always has length 0......

public static void main(String[] args) {

        String fileName = "myfile.xml";

        if(args==null || args.length==0){  // Fall back
            System.out.println("Using "+fileName.toString());
        } else {
            fileName=args[0];
        }
Comment 1 Jiri Prox 2009-08-17 13:27:09 UTC
Can you please provide more info?

What project do you use?
How do you launch the application (there several way run main project, run single file etc..)
Do you have more run configuration?

Thanks
Comment 2 dizzzz 2009-08-17 15:24:40 UTC
Right, I found out what is wrong...

-1- if I run the app with a main main class defined, by using F6 / run main project the parameters are passed okay
-2- if I run the class directly (shift F6) these application parameters are NOT passed (did not check jvm settings yet)

I am not sure what one would expect for 2, My assumption was (is?) that the run parameters as defined in the project
properties would be used for the Run-File execution as well.

Comment 3 Jiri Prox 2009-08-17 16:54:21 UTC
You're right, there is issue for this problem - issue 68099

As a workaround you can use run configuration or modify your build-imlp.xml (in this case you have to turn off compile
on save feature). 
The modification is to rewrite target run-single to this code
<target depends="init,-do-not-recompile,compile-single" name="run-single">
        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
        <j2seproject1:java classname="${run.class}">
            <customize>
                <arg line="${application.args}"/>
            </customize>
        </j2seproject1:java>
    </target>

*** This issue has been marked as a duplicate of 68099 ***
Comment 4 dizzzz 2009-08-17 17:59:52 UTC
Right, sorry for the fuzz, I wonder why I did not find this duplicate. Sorry for the extra work....