java -jar 传参

public class MainClass {

	private static String txtPath;
	private static String excelPath;

	
	public static void main(String[]a) throws IOException {
		// TODO Auto-generated method stub

		if (a.length ==2) {
	
		txtPath=a[0];
           
	     	excelPath=a[1];
			
		} else {
		txtPath = "E:\\test.txt";
		excelPath="E:\\success.xlsx";
		}}}

在java -jar name.jar a b c .....命令中,把abc等元素放入String[]a中,然后从数组中提取 java -jar 传参_第1张图片
 
 

你可能感兴趣的:(java -jar 传参)