如何在带有参数的cmd中运行Java程序 [英] How to run a java program in cmd with arguments

查看:240
本文介绍了如何在带有参数的cmd中运行Java程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个初学者的问题。我试图从带有参数的cmd运行Java程序。
这是我的课程:

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);
    }
}

我可以在没有参数的情况下成功运行它。我该如何在程序中放入例如5和6作为参数?

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.

推荐答案

java Test arg1 arg2 arg3 ...

java Test "arg1 arg2 arg3" ...

更多此处的详细信息命令行参数

这篇关于如何在带有参数的cmd中运行Java程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆