在 OS X 上运行 ProGuard:Apple 的 rt.jar 等价物在哪里?
我正在运行 ProGuard 来缩小我的 jar 文件。它需要的参数之一是系统的运行时 jar。在 Sun 发行版上,该文件位于 $JAVA_HOME/lib/rt.jar
中,但在 Apple 的 Mac OS X 上则不然(在我的例子中是 v10.6 (Snow Leopard))。
有适用于 OS X 的 rt.jar 吗?
I'm running ProGuard to shrink my jar file. One of the parameters it needs is the system's runtime jar. This is at $JAVA_HOME/lib/rt.jar
on Sun distributions, but not on Apple's Mac OS X (v10.6 (Snow Leopard) in my case).
Is there an rt.jar for OS X?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
它名为classes.jar,位于/System/Library/Frameworks/JavaVM.framework/Classes 下,
查看此处了解详细信息:
http://lists.apple.com/archives/java-dev/2003/Mar/msg01530.html
It is called classes.jar and it is under /System/Library/Frameworks/JavaVM.framework/Classes
Look here for details:
http://lists.apple.com/archives/java-dev/2003/Mar/msg01530.html
此博客条目介绍了这是一种无需修改 Proguard 配置即可解决问题的相对直接的方法。
该条目建议创建两个符号链接,以便
rt.jar
和jsse.jar
存在于 Proguard 期望的路径中。站在
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib
目录中并运行以下命令解决了我的问题:This blog entry describes a relatively straight-forward way to resolve the issue without modifying the Proguard configuration.
The entry recommends that two symbolic links are created, so that
rt.jar
andjsse.jar
exist in the path that Proguard expects them to.Standing in the
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib
directory and running the following commands resolved the problem for me:在 我应该在 OSX 上将 JAVA_HOME 设置为什么 问题。
简短的答案是使用
/usr/libexec/java_home
的结果或将JAVA_HOME
设置为$(/usr/libexec/java_home)
然后在JAVA_HOME/bundle/Classes/classes.jar
中找到classes.jar
(OS X 中的 rt.jar 等效项)There's some explanation of how to get to the
rt.jar
equivalent in the What should I set JAVA_HOME to on OSX question.The short answer is to use the result of
/usr/libexec/java_home
or to setJAVA_HOME
to$(/usr/libexec/java_home)
and then findclasses.jar
(the OS X equivalent of rt.jar) atJAVA_HOME/bundle/Classes/classes.jar
在我的系统(带有 JDK1.8 的 Mojave 10.14.3)上,除了 gradle 缓存(
~/.gradle/caches/
)之外,没有classes.jar
。但是,/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home/jre/lib/rt.jar
中有一个rt.jar
。我以与 Henrik 从Contents/Home/lib
文件夹中相同的方式链接它和jsse.jar
:Proguard 现在可以工作了。
On my system (Mojave 10.14.3 with JDK1.8), there is no
classes.jar
except in gradle caches (~/.gradle/caches/
). There is, however, anrt.jar
in/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home/jre/lib/rt.jar
. I linked it andjsse.jar
in the same way as Henrik from theContents/Home/lib
folder:and Proguard works now.
对我来说,原因是我安装了 JDK 13。安装 JDK 1.8 后,该文件出现在 ProGuard 预期的位置。安装 JDK 1.8 后,您可以运行 sudo find /Library -name rt.jar 来查找 rt.jar 的确切路径
For me the reason was I had JDK 13 installed. After installing JDK 1.8 the file appeared in the location expected by ProGuard. You can run
sudo find /Library -name rt.jar
to find the exact path to thert.jar
after installing JDK 1.8