Launching jarsigner.exe on windows os which jdk/jre not installed by installer

你离开我真会死。 提交于 2019-12-07 19:03:19

问题


I've embedded jre files to my applications setup, i can use java.exe to perform some java specific tasks.

And i want to use jarsigner.exe but when i launch jarsigner, it checks some registry keys, and could not found (because jre is not insatalled by jre setup) them and gives error.

How can i specify java.exe path to jarsigner

so that it should use java.exe that i point instead of checking registry.

error log:

Error opening registry key 'Software\JavaSoft\Java Runtime Environment

Error: could not find java.dll

Error: could not find Java SE Runtime Environment

I wonder are there any extra parameters for jarsigner may be that defines JAVA_HOME dir, or anything else that defines where java.exe is exists.


回答1:


There are no specific command-line parameters, however while invoking jarsigner, you can still set the java.home property to point to your desired JRE bundled with your application.

For instance, you could invoke the jarsigner with either:

  • ProcessBuilder and set the java.home property,
  • or a variant of Runtime.exec() allowing to set the envp environment variables,
  • or a batch/shell script and set the JAVA_HOME property in it.



回答2:


To make jarsigner work with JRE instead of JDK. Need to bundle these files in JRE from JDK

From \bin\jarsigner.exe to \bin\jarsigner.exe From \bin\msvcr100.dll to \bin\msvcr100.dll From \bin\jli.dll to \bin\jli.dll From \lib\tool.jar to \lib\tool.jar I tested with this and found it working for me.




回答3:


Stolen from Java Error opening registry key

Remove if any.

on 32 bit machine

java.exe, javaw.exe and javaws.exe from your Windows\System32 folder

on 64 bit machine

remove from Windows\SysWOW64.



来源:https://stackoverflow.com/questions/10991856/launching-jarsigner-exe-on-windows-os-which-jdk-jre-not-installed-by-installer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!