Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
467 views
in Technique[技术] by (71.8m points)

gradle - Unwanted default cmd line arguments when Java program is started from IDEA

I am using IntelliJ IDEA in version 2020.3.1 on Ubuntu 20.04.1 LTS. I am writing Java code based on Java 15, using modules; as build system, I am using Gradle 6.7.1.

One component is a simple helper tool that takes data from the command line; the problematic behaviour can easily be reproduced with this code:

public final class Start
{
    public static final void main( final String... args )
    {
        System.out.println( Arrays.toString( args ) );
    }
}

When I place that class under $PROJECT/src/main/java/pkg, right click on it in IDEA, and select "Run" from the context menu, I get as output

[-Dfile.encoding=UTF-8, -Duser.country=DE, -Duser.language=de, -Duser.variant, pkg.Starter]

Placing the same code to $PROJECT/src/test/java/pkg and doing the same will result to just [] as the output.

In both cases, IDEA utilises Gradle to execute the program.

Same when I select "Debug".

I cannot find any configuration where I could switch off that behaviour (I do not want any "automatic" arguments). And, by the way, the arguments are JVM arguments and not meant for the program.

Any ideas or hints?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...