Run program.exe from eclipse plugin project

前端 未结 2 1730
悲哀的现实
悲哀的现实 2021-01-28 13:00

I am writing an eclipse-plugin witch run program.exe. I have added program.exe to plugin jar file. How can a execute this program?

public class Handler extends A         


        
2条回答
  •  孤城傲影
    2021-01-28 13:42

    You can't run the program.exe from inside the plugin jar, so it needs to be extracted. In your plugin use:

    Bundle bundle = Platform.getBundle("plugin id");
    
    URL url = FileLocator.find(bundle, new Path("relative path to program"), null);
    
    url = FileLocator.toFileURL(url);
    

    This will find the program in the plugin jar and extract it to a temporary location (done by FileLocator.toFileURL).

提交回复
热议问题