-2

Lets say I want to download a game that is written in Java, do I need to install a JDK to run it? Or does the game come bundled with a JDK?

Henry Twist
  • 5,666
  • 3
  • 19
  • 44
  • Well ... I don't think there is a dup because there isn't really an answer. In some cases the downloadable will be an installer that may or may not install a JRE for you. In other cases, the downloadable will be a JAR file, and the user needs to deal with Java installation separately? How do you know? Read the instructions that come with the game. No instructions? Ask the author. Can't contact the author? Do you really, really think it is a good idea to run some application (binary) which doesn't have instructions, and the author is uncontactable??? – Stephen C Nov 01 '21 at 01:11
  • And ... this is not really a programming question. It is about how to install some (unspecified) game code. – Stephen C Nov 01 '21 at 01:13
  • 1
    this is just an example its not about a game by itself i meant that if any java program requires a jre to run how does people who doesn't have a jre run these programs? @StephenC – Abdelrahamn Nov 01 '21 at 13:28
  • OK. So what about this? https://stackoverflow.com/questions/3014187. Or this? https://stackoverflow.com/questions/48605576. Admittedly, the answers to those questions are not very well written, but then ... – Stephen C Nov 01 '21 at 13:38

1 Answers1

1

Either.

When a developer compiles and builds their Java app, the typical artifact produced is a JAR file.

To execute the app, to run that JAR, the user runs the java command-line tool bundled with a JDK. A JDK can be obtained from any of several vendors including Azul Systems, Pivotal, Adoptium (formerly AdoptOpenJDK), Microsoft, Oracle, BellSoft, Amazon, SAP, Red Hat/IBM, etc. Some are free-of-cost without direct support, some require a fee and come with a support plan. See Java Is Still Free.

Expecting a JDK to be present on each user’s computer may be practical in a controlled environment, such as a corporate office or a school. But in other situations, such as distributing the app to the public or via an app market, expecting a user to have installed a JDK may not be workable. In such a case, the developer can bundle a JDK within the app. This approach results in a « double-clickable » application that executes in the same manner as native non-Java apps.

As of Java 9 and later, the JDK can be stripped down to the bare minimum of parts needed for the particular app, via the Java Module System. This makes for a smaller executable, which means faster downloads and less space taken in the end-user’s storage. See the jlink and jpackage tooling. This approach requires the developer to produce an executable artifact for each platform they choose to support, such as macOS, Windows, BSD, Linux, on each chip architecture they choose to support such as Intel 32-bit, AMD64, AArch64, POWER, etc.

On the cutting edge, some people are using GraalVM to build a native app, compiled to machine language ahead of time.

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154