运行位于SDK之外的Java可执行文件

huangapple 未分类评论46阅读模式
英文:

Running a java exe out of the SDK

问题

我使用Java 8(JDK 8)创建了一个程序,但当我尝试在一台没有安装JDK的设备上运行它时,它让我下载一个JRE。

  1. 为什么并不是所有下载的程序都需要这样做?这只是因为大多数程序没有使用Java吗?
  2. 我如何创建一个安装exe文件,以安装JRE和程序。(目前我只是将我的程序作为exe文件运行)。
英文:

I created a program using Java 8(JDK 8), but when I try to run it on a device that isn't mine (so no JDK), it makes me download a JRE.

  1. why don't all programs when you download them make you do this? Is it just most programs aren't using Java?
  2. how to I create an installation exe to install the JRE and the program. (As of now I'm just running my program as an exe).

答案1

得分: 0

> 是不是大多数程序都不使用Java?

是的,Java是一种流行的编程语言,但大多数(桌面)应用程序并非是用Java编写的。

有些程序也会附带JRE,这意味着它会随程序一起安装。

> 我如何创建一个安装exe来安装JRE和程序。

这个exe可以尝试从例如OpenJDK的API中下载JRE,执行它,并等待直到它完成,你可以携带一个安装程序,你可以告诉用户安装JDK,或者你可以使用一个安装程序模板,让模板为你执行其中的一些步骤。

英文:

> Is it just most programs aren't using Java?

Yes, java is a popular programming language but most (desktop) applications are not written in java.

Some programs do also come with a JRE, meaning that it is installed with the program.

> how to I create an installation exe to install the JRE and the program.

The exe could try to download the JRE from the API of e.g. OpenJDK, execute it and wait until it finishes, you could bring an installer with you, you could tell the user to install a JDK or you use an installer template that does one of the things for you.

huangapple
  • 本文由 发表于 2020年4月10日 05:46:03
  • 转载请务必保留本文链接:https://java.coder-hub.com/61130723.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定