访问在java程序中编译的资源 [英] Accessing resources compiled in a java program

查看:91
本文介绍了访问在java程序中编译的资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

帮助我,我写了一个java程序,并在同一个程序中的一个文件夹(作为一个reseource)中添加了一个aapt.bat文件。我希望使用命令提示符运行aapt.bat。

应用程序在IDE中正常运行但是当我将应用程序编译为.jar文件并运行它时,我从命令提示符获得如下错误。



'文件:'不被识别为内部或外部命令,







file:/ C:/Users/slab1/Pictures/training/dist/training.jar!/res/aapt.exe list C:\ Reversing\Apk \\ \\tools\GApp1.6.apk。



我想要实现的是运行jar文件cmd中的aapt.bat。

谢谢



我尝试过:



Help me, l wrote a java program and l added a aapt.bat file in a folder(as a reseource) in the same program. l want the aapt.bat run using command prompt.
The application runs fine from the IDE but when l compiled the application to a .jar file and run it, l get error as below from the command prompt.

'file:' is not recognized as an internal or external command,

and

file:/C:/Users/slab1/Pictures/training/dist/training.jar!/res/aapt.exe list C:\Reversing\Apk\tools\GApp1.6.apk.

What l want to achieve is to run the aapt.bat filed in the jar file cmd.
Thanks

What I have tried:

public boolean decodes(String file)
  {
    Runtime runtime = Runtime.getRuntime();

    System.out.println("Android Path: " + getDexToolPath() + " -f -o " + getWorkPlace() + Base.getSeparator() + getFileName(file) + ".jar " + file);
    try {
      Process process = runtime.exec(getDexToolPath() + " -f -o " + getWorkPlace() + Base.getSeparator() + getFileName(file) + ".jar " + file);

      process.waitFor();
      return true;
    } catch (IOException ex) {
      return false; } catch (InterruptedException ex) {
    }
    return false;
  }

推荐答案

你不能。 CMD提示符仅适用于文件系统。您的应用程序不是文件系统的一部分,因此CMD无法看到已编译的应用程序中的内容并使用它就像它一样。



CMD可以到达的唯一方式批处理文件并运行它是否是一个显示在驱动器上的文件夹中的单独文件。
You can't. The CMD prompt will only work with the file system. Your application is not part of the file system, so CMD cannot see what's inside the compiled app and use it as if it was.

The only way CMD can get to the batch file and run it is if it is a separate file that shows up in a folder on the drive.


这篇关于访问在java程序中编译的资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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