简体   繁体   English

applet执行无法执行打包在可执行jar中的批处理文件

[英]applet execution fail to execute batch file packaged inside executable jar

I am executing a bat file through my java program. 我正在通过Java程序执行bat文件。 the path is hardcoded in java. 路径是用Java硬编码的。

I have packaged bat file in the jar.and jar contains main class as an applet class. 我已经将bat文件打包在jar中。jar包含主类作为applet类。

i am calling this jar file from jsp page as applet. 我从jsp页面将此applet文件称为applet。

applet run successfully but couldn't run bat file inside init. 小程序成功运行,但无法在init中运行bat文件。

If i give hard coded path then it executes ...but can't execute taking from jar. 如果我给出了硬编码的路径,那么它将执行...但是无法执行从jar中获取。

Any hints for packaging such jar ie having a bat file inside and able to run it as dynamic applet? 是否有任何包装此类jar的提示,即在其中包含bat文件并能够将其作为动态applet运行?

You're trying to make two impossible things here: 您正在尝试在此处做出两项不可能的事情:

  • execute a batch file from an applet. 从小程序执行批处理文件。 This would need a signed applet and permissions granted by the user, because obviously, launching an external program from an applet downloaded from the web is very very very insecure. 这将需要签名的applet和用户授予的权限,因为显然,从从Web下载的applet启动外部程序是非常非常不安全的。
  • execute a batch file which is not on the file system. 执行不在文件系统上的批处理文件。 cmd.exe expects the filesystem path of the batch file to execute. cmd.exe希望执行批处理文件的文件系统路径。 It won't be able to find the batch file in the jar which only exists in the memory of the browser. 它将无法在仅存在于浏览器内存中的jar中找到批处理文件。 You would need to write the batch file to the file system (which, once again, would need a signed applet and granted permissions, because letting an applet writing on the local hard drive is very very insecure), and then execute this batch file. 您将需要将批处理文件写入文件系统(这再次需要一个签名的applet和已授予的权限,因为让applet在本地硬盘驱动器上写入是非常不安全的),然后执行该批处理文件。

Applets run in a security sandbox. 小程序在安全沙箱中运行。 You need to learn about it. 您需要了解它。 Read http://download.oracle.com/javase/tutorial/deployment/applet/security.html 阅读http://download.oracle.com/javase/tutorial/deployment/applet/security.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM