0

When we import a class from our own source file, we have to compile it and generate its .class file, so that we can give the classpath to the other source file which is importing. But when we import classes from java standard libraries, which are stored in the src folder of the java jdk, are they also compiled, and if yes, then where is the .class file of them????

1 Answers1

0

The src folder of the java jdk is not used/needed; its installation is optional, usually for documentation purposes. When resolving the imports, only the compiled classes (usually packed in jars) are used.

Regarding the .class files, it depends on the jre/jdk installation platform/version. For example:

    jar tvf /usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/rt.jar | tail
   109 Mon Aug 03 01:53:14 PET 2020 java/lang/Cloneable.class
   233 Mon Aug 03 01:53:14 PET 2020 java/lang/reflect/Type.class
  3416 Mon Aug 03 01:53:14 PET 2020 java/lang/reflect/AnnotatedElement.class
   304 Mon Aug 03 01:53:14 PET 2020 java/lang/reflect/GenericDeclaration.class
 34224 Mon Aug 03 01:53:14 PET 2020 java/lang/Class.class
  1918 Mon Aug 03 01:53:10 PET 2020 java/lang/CharSequence.class
   235 Mon Aug 03 01:53:10 PET 2020 java/lang/Comparable.class
   113 Mon Aug 03 01:53:10 PET 2020 java/io/Serializable.class
 18936 Mon Aug 03 01:53:10 PET 2020 java/lang/String.class
  1497 Mon Aug 03 01:53:10 PET 2020 java/lang/Object.class
DBE
  • 290
  • 4
  • 9