Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Beginning Java and the fly likes rt.jar file questions (import, size, redundancy) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "rt.jar file questions (import, size, redundancy)" Watch "rt.jar file questions (import, size, redundancy)" New topic
Author

rt.jar file questions (import, size, redundancy)

You Gin
Ranch Hand

Joined: Jul 23, 2010
Posts: 52
Hi guys,

What I've noticed is that rt.jar is located in both JDK and JRE:
"c:\Program Files\Java\jdk1.6.0_21\jre\lib\rt.jar"
"c:\Program Files\Java\jre6\lib\rt.jar"

Several questions arise at the same time. Do you mind I'll list them all?

Here are they:

1. Which of them is using when I do import something in my code?
2. Why the size of these two is different?
3. Does it mean I can simply remove the jre6 folder and still be able to run java applications (as long as JRE is included in JDK)?

Jeff Friesen
author
Ranch Hand

Joined: Sep 19, 2010
Posts: 41
Hi You,

On my Windows XP platform, I have JDK 6 Update 16 installed in my C:\Program Files\Java\jdk1.6.0_16 directory, and JRE 6 Update 21 installed in my C:\Program Files\Java\jre6 directory. The size of the rt.jar file in my C:\Program Files\Java\jdk1.6.0_16\jre\lib directory is 49,396,545 bytes, and the size of the rt.jar file in my C:\Program Files\Java\jre6\lib directory is 44,655,521 bytes. The difference in rt.jar file sizes is due to two different versions of Java, and I suspect this is what you have as well.

At your command line, execute java -version and javac -version. Do the version numbers agree or are they different? They probably are different.

When I compile a Java source file at the command line, I'm using JDK 6 Update 16. When I run an application via java at the command line, I'm using JRE 6.

I could remove my JRE 6 folder (which got installed when I ran a JavaFX application that needed a more recent update) and then my java command would indicate JDK 6 Update 16.

Hope this helps.

Jeff


http://javajeff.mb.ca
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19557
    
  16

Jeff Friesen wrote:On my Windows XP platform, I have JDK 6 Update 16 installed in my C:\Program Files\Java\jdk1.6.0_16 directory, and JRE 6 Update 21 installed in my C:\Program Files\Java\jre6 directory. The size of the rt.jar file in my C:\Program Files\Java\jdk1.6.0_16\jre\lib directory is 49,396,545 bytes, and the size of the rt.jar file in my C:\Program Files\Java\jre6\lib directory is 44,655,521 bytes. The difference in rt.jar file sizes is due to two different versions of Java, and I suspect this is what you have as well.

Actually, even with the same version this issue occurs.

I have not installed any JRE separately, only as part of the JDK. That means that my JRE and JDK are both the same version, 1.6.0u21. My JDK's rt.jar has a size of 49,785,005 bytes, the JRE's rt.jar has a size of 44,655,521 bytes.

I just did a file comparison on the contents of both JAR files (them being ZIP files), and the class files are different (except 24 of them...). The present class files are the same in both files. It just seems like the API classes have been compiled twice, once for the JDK and once for the JRE. Perhaps the debugging settings are different; if I call "".substring(0, 25); with my JDK's java.exe I see the file name and line number where the exception occurs, with my JRE's java.exe I see "Unknown Source".


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: rt.jar file questions (import, size, redundancy)
 
Similar Threads
classpath
Basic Question
JAVA_HOME does not point to the JDK
troubles importing CachedRowSetImpl
problem calling a remote webservice [ Algo Error]