windows 是否可以使用 Java webstart 执行 .exe 或 dll?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/831050/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is it possible to use Java webstart execute .exe or dll?
提问by Roy Chan
I know java webstart is running under a secure sandbox. Is it possible to include a .dll/.exe in the jar (or have the webstart download it to the local machine) and then execute it (using Runtime.exec or process,etc)
我知道 java webstart 正在安全沙箱下运行。是否可以在 jar 中包含 .dll/.exe(或让 webstart 将其下载到本地机器)然后执行它(使用 Runtime.exec 或 process 等)
Please Advise. Any suggestion/comment is welcome!
请指教。欢迎任何建议/评论!
回答by Brian Agnew
Yes. You have to wrap the .dll
in a .jar
file, and reference it in your .jnlp
file using <nativelib>
是的。您必须将其包装.dll
在一个.jar
文件中,并.jnlp
使用<nativelib>
See herefor a more detailed description.
有关更详细的说明,请参见此处。
If you want to run an executable, then your best bet is to package it up in your .jar
as a resource, explode it to (say) a temporary directory, and then run it using the normal Process/Runtime mechanism.
如果你想运行一个可执行文件,那么你最好的办法是将它打包在你.jar
的资源中,将它分解到(比如)一个临时目录,然后使用正常的进程/运行时机制运行它。
回答by jsight
Yes, as long as the user grants your application privileges (via the dialog that pops up), then Java webstart will have access to the file-system, and will have permission to use Runtime.exec.
是的,只要用户授予您的应用程序权限(通过弹出的对话框),那么 Java webstart 将有权访问文件系统,并有权使用 Runtime.exec。