46

Possible Duplicate:
Why do we use rt.jar in a java project?

I am very confused to knowing about rt.jar file.

What is the role of rt.jar file or use of rt.jar file in java??

Thanks.

Community
  • 1
  • 1
Ravi
  • 673
  • 1
  • 5
  • 13

2 Answers2

56

rt.jar contains all of the compiled class files for the base Java Runtime environment. You should not be messing with this jar file.

For MacOS it is called classes.jar and located under /System/Library/Frameworks/<java_version>/Classes . Same not messing with it rule applies there as well :).

http://javahowto.blogspot.com/2006/05/what-does-rtjar-stand-for-in.html

Saleh
  • 1,819
  • 1
  • 17
  • 44
CoolBeans
  • 20,654
  • 10
  • 86
  • 101
  • I heard that MacOSX doesnt have this file. If so, why? – djangofan Sep 08 '11 at 22:15
  • 5
    It's there in MacOSX under a different name `classes.jar` and it is under `/System/Library/Frameworks//Classes` . – CoolBeans Sep 08 '11 at 22:28
  • 10
    note - as of java 1.7, apple no longer distributes the jdk. The jdk from Oracle is in a different location /Library/Java/JavaVirtualMachines/jdk1.7.0_xx.jdk and has rt.jar not classes.jar – Jay Feb 28 '13 at 19:26
  • Usually you are able to find the jar file at `$JAVA_HOME/jre/lib/rt.jar` – z11i Nov 25 '19 at 07:05
  • This is a very old answer, but it is still true after all these years. I figured out today. – Marco Schoolenberg May 17 '21 at 01:49
8

Your question is already answered here :

Basically, rt.jar contains all of the compiled class files for the base Java Runtime ("rt") Environment. Normally, javac should know the path to this file

Also, a good link on what happens if we try to include our class file in rt.jar.

Community
  • 1
  • 1
Saurabh Gokhale
  • 53,625
  • 36
  • 139
  • 164