简体   繁体   English

尝试使用JarSigner.exe签名apk文件时出现NoClassDefFoundError

[英]NoClassDefFoundError while trying to sign an apk file using JarSigner.exe

I try to sign an android application using the file JarSigner.exe (In windows). 我尝试使用文件JarSigner.exe(在Windows中)对android应用程序进行签名。

What I did was creating a designated dir in which I placed the JarSigner.exe along with all the other files in JRE\\bin. 我所做的是创建一个指定的目录,在其中将JarSigner.exe以及所有其他文件放在JRE \\ bin中。

Of course I also put there the keystore file. 当然,我也将密钥库文件放在了那里。

I openned a cmd window (as an administrator) and changed dir to the designated dir I created. 我以管理员身份打开一个cmd窗口,并将目录更改为我创建的指定目录。

There I gave the command: 在那里,我给出了命令:

jarsigner -keystore myKeystore myApp.apk myself

The result was as follows: 结果如下:

Exception in thread "Main Thread" java.lang.NoClassDefFoundError: sun/security/t
ools/JarSigner
Caused by: java.lang.ClassNotFoundException: sun.security.tools.JarSigner
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: sun.security.tools.JarSigner.  Program will exit.

Does someone know why does it happen, or how can I fix it? 有人知道为什么会发生这种情况吗,或者我该如何解决?

What I did was creating a designated dir in which I placed the JarSigner.exe along with all the other files in JRE 我所做的是创建一个指定的目录,在其中将JarSigner.exe以及所有其他文件放在JRE中

That was your mistake. 那是你的错 What you should have done was adjust the PATH to include the JDK bin directory, or provide the full path to jarsigner,exe when running it. 您应该做的是调整PATH以包含JDK bin目录,或者在运行它时提供jarsigner,exe的完整路径。

you must be add tools.jar to your classpath you can look this link for more information 您必须将tools.jar添加到您的类路径中,您可以查看此链接以获取更多信息

how you can add JAR in to Classpath in Java 如何在Java中将JAR添加到Classpath中

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

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