27

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?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
dacracot
  • 22,002
  • 26
  • 104
  • 152

5 Answers5

22

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

Vlad
  • 9,180
  • 5
  • 48
  • 67
  • 1
    On my system (Mojave 10.14.3), there is no classes.jar except in gradle caches (~/.gradle/caches/). There *is*, however, an rt.jar in /Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home/jre/lib/rt.jar. – drkvogel Mar 25 '19 at 10:44
12

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 and jsse.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:

sudo ln -s ../../Classes/classes.jar rt.jar
sudo ln -s ../../Classes/jsse.jar .
Henrik Aasted Sørensen
  • 6,966
  • 11
  • 51
  • 60
4

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 set JAVA_HOME to $(/usr/libexec/java_home) and then find classes.jar (the OS X equivalent of rt.jar) at JAVA_HOME/bundle/Classes/classes.jar

Community
  • 1
  • 1
Bryan J Swift
  • 1,449
  • 2
  • 15
  • 17
1

On my system (Mojave 10.14.3 with JDK1.8), there is no classes.jar except in gradle caches (~/.gradle/caches/). There is, however, an rt.jar in /Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home/jre/lib/rt.jar. I linked it and jsse.jar in the same way as Henrik from the Contents/Home/lib folder:

➜  lib sudo ln -s ../jre/lib/rt.jar 
➜  lib sudo ln -s ../jre/lib/jsse.jar

and Proguard works now.

drkvogel
  • 2,061
  • 24
  • 17
0

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 the rt.jar after installing JDK 1.8

Vlad Holubiev
  • 4,876
  • 7
  • 44
  • 59