0

JRE is implementation of JVM specification and has to be platform dependant.

One of the main purpose of JDK is to compile source code and produce .class files. Is JDK written in Java ? If yes , why do we have different jdk for different OS.

Or is JDK written in C or some other language with implementations specific to OS ( Windows / MAC etc )?

2
  • This MUST be a duplicate! Commented Jun 26, 2021 at 13:00
  • The JDK applications are not platform independent, it is Java as a software development and software execution platform that is platform independent. Commented Jun 26, 2021 at 13:28

3 Answers 3

1

Large portions of the JDK consists of native code, that needs to be compiled to be able to run on the target platform. In theory, toolchain and operating system should be independent factors, but in practice there's more or less a one-to-one correlation between target operating system and toolchain. (see official documentation https://openjdk.java.net/groups/build/doc/building.html)

Sign up to request clarification or add additional context in comments.

Comments

0

Most JDK implementations are mostly written in Java, but have some natively implemented methods (e.g., most methods in java.lang.Object).

1 Comment

Other good examples are the nio and network libraries, which interact with the native APIs of the underlying operating system.
-1

why do we have different jdk for different OS.

Minimally, because a JDK normally includes a JRE, and JREs are necessarily system dependent.

Additionally, it is common for some of the JDK components outside the JRE, such as the Java compiler, to be implemented with native code.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.