![](/img/trans.png)
[英]Hadoop MapReduce program runs fine in Eclipse but not when exported to .jar file
[英]Batch file runs when executing my program on eclipse but the has issue when jar file is used
我正在嘗試使用Java程序從我的Android手機中提取應用程序。 調用我的批處理文件的代碼是:-
public static void batch(String a,String b) throws InterruptedException
{
try {
fchooser fc=new fchooser();
String fg=fc.antd;
String arg1=a;
String userinp1=b;
String dir=System.getProperty("user.dir");;
JOptionPane.showMessageDialog(null, "this is batchrun and path is "+fg);
Process pan = Runtime.getRuntime().exec(new String[] {"C:\\test1.bat",arg1,fg});
pan.waitFor();
............
arg1和fg是兩個傳遞給批處理文件的參數。
arg1= /system/app/Chrome
fg= C:\Users\sumeet.p1\Desktop\test2
批處理文件是
cd %2
adb pull %1
pause
在eclipse中,程序運行良好,並將文件提取到fg中指定的位置[在這種情況下-C:\\ Users \\ sumeet.p1 \\ Desktop \\ test2],但是當我使用該程序的jar文件時,文件將被提取到保存jar文件的文件夾,而不是fg中指定的位置。 任何幫助,將不勝感激。 謝謝 :)
我想問題出在您的批處理腳本中的cd %2
行。 當您從命令行jar執行目錄時,由於驅動器的更改,目錄可能未按預期更改。
請查看將其更改為cd /d %2
如下所示:
cd /d %2
adb pull %1
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.