如何在执行时将参数传递给 jar 文件? [英] How do I pass parameters to a jar file at the time of execution?

查看:15
本文介绍了如何在执行时将参数传递给 jar 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在执行时将参数传递给 JAR 文件?

How do I pass parameters to a JAR file at the time of execution?

推荐答案

向 jar 传递参数:

To pass arguments to the jar:

java -jar myjar.jar one two

您可以在Main-Class"的 main() 方法中访问它们(在 JAR 的 manifest.mf 文件中提到).

You can access them in the main() method of "Main-Class" (mentioned in the manifest.mf file of a JAR).

String one = args[0];  
String two = args[1];  

这篇关于如何在执行时将参数传递给 jar 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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