问题
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?
回答1:
They are spread between several jars. It looks like Button is in jre/lib/rt.jar though.
回答2:
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.
回答3:
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.
回答4:
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);
来源:https://stackoverflow.com/questions/459268/where-are-the-class-files-located-in-jdk-folder