简体   繁体   中英

Where are the class files located in JDK folder?

This may sound like a stupid question. Where are the core class files from Sun, like Button.class , located in the JDK installation folder C:\\Program Files\\Java\\jdk1.5.0_12 ?

Or do the class files reside in C:\\Program Files\\Java\\jre1.5.0_12 folder?

They are spread between several jars. It looks like Button is in jre/lib/rt.jar though.

The class files actually reside as jar files inside the Java distribution being used. Most files are in rt.jar (runtime).

Most developer machines actually have two forms of Java installed. The JDK (which you would often be using when developing and includes the compiler), and the JRE which is used by downloaded Java based applications, and often your web browser. Those are typically two independent distributions that don't know about each other. So the answer to your question is unfortunately, "depending what it is that you are running". To make things worse, the JDK may include it's own copy of the JRE...

This is one of the sources of the so-called classpath hell, because it is not always clear what you are using when you are running a java program.

If you run java from the command line, you can sometimes detect the exact version being used.

If you use Eclipse, you can pick version of the JDK you are working with.

You can check out yourself for any class through reflection.

For example where can I find my String class located in the classpath? Easy

URL url = String.class.getResource("String.class");
System.out.println(url);

On Both.

They are two different JVM's installations. One used to compile ( JDK stands for Java Development Kit ) and the other is the java environment which most customers machine have ( JRE stands for Java Runtime Environment )

Look on any of those two for a file named:

rt.jar

That where the core of the platform resides.

There are actually contained in the JRE. Although, the JDK have her copy of the JRE so we may be tempted to say both JDK and JRE but in reality java inbuild classes are contained in the JRE.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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