Tom Magaro
Tom Magaro

Reputation: 167

Testing for Java SDK

I am writing an application in Java. Does a Java SDK have to be installed to run the application from the command line? If so, can I package the SDK with the application to be installed when installing the application?

Upvotes: 0

Views: 193

Answers (3)

Stephen C
Stephen C

Reputation: 718708

From Java 9 onwards you can use jlink to produce a custom JRE for your application. The JRE includes a copy of the java command and (only) the libraries / classes that your application needs. It will be platform specific.

From Java 14 onwards, you can use jpackage to produce (platform specific) native executables for Java applications.

There are also 3rd-party tools that can generate executables, and third party installer generators that (in some cases) can install Java for the end user.

Note: if you take the approach of distributing your application as a self-contained JRE or native executable, the user no longer has the option of updating their Java to address security related issues. It becomes your problem / responsibility ... as the supplier of the software ... to make available in a timely fashion application updates that incorporate the new Java releases with important security patches.

Upvotes: 1

Tom Magaro
Tom Magaro

Reputation: 167

Thanks everyone for your input.

After doing more research I found that by using a jdk greater than 8.?, it is possible to bundle everything an application needs in the deployment process.

Upvotes: 1

OneCricketeer
OneCricketeer

Reputation: 191681

If you use something like GraalVM to compile a native binary, then there is nothing more you should need for a simple application (meaning, nothing is tried to dynamically load classes at runtime with reflection)

Other than that, the Java JRE is required, and can be included as part of an application package; for example, IntelliJ or Eclipse IDE come with their own JRE.

Upvotes: 1

Related Questions