如何在通过命令行运行时获取jar执行路径 [英] How to get jar execution path while running via command line

查看:263
本文介绍了如何在通过命令行运行时获取jar执行路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个jar文件,必须通过命令行执行。一个xml文件还添加了包含日志路径设置的源包。我的问题是如何设置程序集执行路径,以便我必须得到xml。目前我已经嵌入了



 FileInputStream fileIn =  new  FileInputStream(System .getProperty(  user.dir)+   \\src\\ProjName \\Config.xml); 





虽然将jar文件和xml提供给第三方,我该如何处理?

解决方案

最好使用亲戚路径比绝对路径。



使用下面的声明,



FileInputStream fileIn = new FileInputStream(\\ \\\src\\ProjName\\Config.xml);

I have been created a jar file which has to be executed thru command line. One xml file also added source package with log path settings. My question is how to set assembly execution path so that i have to get the xml. Currently i had embeded as

FileInputStream fileIn = new FileInputStream(System.getProperty("user.dir") + "\\src\\ProjName\\Config.xml");



While giving the jar file and xml to third party, how do I handle this ?

解决方案

It is better to use relative path than absolute path.

Use the bellow statement,

FileInputStream fileIn = new FileInputStream("\\src\\ProjName\\Config.xml");


这篇关于如何在通过命令行运行时获取jar执行路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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