How to run a java program in cmd with arguments [duplicate]

╄→гoц情女王★ 提交于 2019-12-24 07:10:03

问题


This is a beginner question. I am trying to run a java program from cmd with arguments. This is my class:

public class Test{
    public static void main(String[] args){
        System.out.println("This is a test");
        System.out.println(args.length);
    }
}

I can run it without arguments successfully. How can I put for example 5 and 6 as arguments in my program?

All the other answers I found where just to run the program. I already know how to do that. I was not able to find how to run the program using arguments.


回答1:


java Test arg1 arg2 arg3 ...

or

java Test "arg1 arg2 arg3" ...

More details here Command-Line Arguments



来源:https://stackoverflow.com/questions/40490628/how-to-run-a-java-program-in-cmd-with-arguments

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!