1. Introduction to EJDK
1.EJDK简介
The EJDK (Embedded Java Development Kit) was introduced by Oracle to solve the problem of providing binaries for all the available embedded platforms. We can download the latest EJDK from Oracle’s site here.
EJDK(嵌入式Java开发工具包)是由Oracle推出的,以解决为所有可用的嵌入式平台提供二进制文件的问题。我们可以从Oracle的网站下载最新的EJDK。
Simply put, it contains the tools for creating platform-specific JREs.
简单地说,它包含了创建特定平台的JREs的工具。
2. jrecreate
2.jrecreate
EJDK provides jrecreate.bat for Windows and jrecreate.sh for Unix/Linux platforms. This tool helps in assembling custom JREs for platforms we wish to use, and was introduced to:
EJDK为Windows提供jrecreate.bat,为Unix/Linux平台提供jrecreate.sh。这个工具有助于为我们希望使用的平台组装定制的JRE,并被介绍给。
- minimize the release of binaries by Oracle for every platform
- make it easy to create customized JREs for other platforms
The following syntax is used to execute the jrecreate command; in Unix/Linux:
以下语法用于执行jrecreate命令;在Unix/Linux中。
$jrecreate.sh -<option>/--<option> <argument-if-any>
And in Windows:
而在Windows中。
$jrecreate.bat -<option>/--<option> <argument-if-any>
Note, we can add multiple options for a single JRE creation. Now, let’s take a look at some of the options available for the tool.
注意,我们可以为一个JRE的创建添加多个选项。现在,让我们看看该工具的一些可用选项。
3. Options for jrecreate
3.jrecreate的选项
3.1. Destination
3.1.目的地
The destination option is required and specifies the directory in which the target JRE should be created:
destination选项是必需的,它指定了应在其中创建目标JRE的目录。
$jrecreate.sh -d /SampleJRE
On running the above command, a default JRE will be created in the specified location. The command line output will be:
在运行上述命令时,一个默认的JRE将被创建在指定的位置。命令行的输出将是。
Building JRE using Options {
ejdk-home: /installDir/ejdk1.8.0/bin/..
dest: /SampleJRE
target: linux_i586
vm: all
runtime: jre
debug: false
keep-debug-info: false
no-compression: false
dry-run: false
verbose: false
extension: []
}
Target JRE Size is 55,205 KB (on disk usage may be greater).
Embedded JRE created successfully
From the above result, we can see that the target JRE is created in the specified destination directory. All the other options have taken their default values.
从上面的结果中,我们可以看到,目标JRE是在指定的目标目录下创建的。所有其他的选项都采用了它们的默认值。
3.2. Profiles
3.2.概况
The profile option is used to manage the size of the target JRE. The profiles define the functionality of the API to be included. If the profile option is not specified, the tool will include all the JRE APIs by default:
profile选项用于管理目标JRE的大小。配置文件定义了要包括的API的功能。如果没有指定profile选项,该工具将默认包括所有的JRE APIs。
$jrecreate.sh -d /SampleJRECompact1/ -p compact1
A JRE with a compact1 profile will be created. We can also use ––profile instead of -p in the command. The command line output will display the following result:
一个带有compact1profile的JRE将被创建。我们也可以用–profile代替命令中的-p。命令行的输出将显示以下结果。
Building JRE using Options {
ejdk-home: /installDir/ejdk1.8.0/bin/..
dest: /SampleJRECompact1
target: linux_i586
vm: minimal
runtime: compact1 profile
debug: false
keep-debug-info: false
no-compression: false
dry-run: false
verbose: false
extension: []
}
Target JRE Size is 10,808 KB (on disk usage may be greater).
Embedded JRE created successfully
In the above result, note that the runtime option has the value as compact1. Also note the size of the result JRE is just under 11MB, down from 55MB in the previous example.
在上述结果中,注意runtime选项的值为compact1。还注意到结果中JRE的大小略低于11MB,比前一个例子中的55MB要小。
There are three available options for the profile setting: compact1, compact2, and compact3.
配置文件设置有三个可用选项。紧凑1,紧凑2,和紧凑3。
3.3. JVMs
3.3. JVMs
The jvm option is used to customize our target JRE with specific JVMs based on the user’s needs. By default, it includes all the available JVMs (client, server, and minimal) if both profile and jvm options are not specified:
jvm选项用于根据用户的需求用特定的JVM来定制我们的目标JRE。默认情况下,如果没有指定profile和jvm选项,它包括所有可用的JVM(客户端、服务器和最小)。
$jrecreate.sh -d /SampleJREClientJVM/ --vm client
A JRE with a client jvm will be created. The command line output will display the following result:
一个带有clientjvm的JRE将被创建。命令行输出将显示以下结果。
Building JRE using Options {
ejdk-home: /installDir/ejdk1.8.0/bin/..
dest: /SampleJREClientJVM
target: linux_i586
vm: Client
runtime: jre
debug: false
keep-debug-info: false
no-compression: false
dry-run: false
verbose: false
extension: []
}
Target JRE Size is 46,217 KB (on disk usage may be greater).
Embedded JRE created successfully
In the above result, note that the vm option has the value Client. We can also specify the other JVMs like server and minimal with this option.
在上述结果中,注意vm 选项的值是Client。我们也可以用这个选项指定其他JVM,如server和minimal。
3.4. Extension
3.4. 扩展
The extension option is used to include various allowed extensions to the target JRE. By default, there are no extensions added:
extension选项用于向目标JRE包括各种允许的扩展。默认情况下,没有添加任何扩展。
$jrecreate.sh -d /SampleJRESunecExt/ -x sunec
A JRE with an extension sunec (Security provider for Elliptic Curve Cryptography) will be created. We can also use ––extension instead of -x in the command. The command line output will display the following result:
一个带有extensionsunec(Elliptic Curve Cryptography的安全提供者)的JRE将被创建。我们也可以在命令中使用–extension而不是-x。命令行输出将显示以下结果。
Building JRE using Options {
ejdk-home: /installDir/ejdk1.8.0/bin/..
dest: /SampleJRESunecExt
target: linux_i586
vm: all
runtime: jre
debug: false
keep-debug-info: false
no-compression: false
dry-run: false
verbose: false
extension: [sunec]
}
Target JRE Size is 55,462 KB (on disk usage may be greater).
Embedded JRE created successfully
In the above result, note that the extension option has the value sunec. Multiple extensions can be added with this option.
在上述结果中,注意extension选项的值为sunec。可以用这个选项添加多个扩展。
3.5. Other Options
3.5.其他选择</b
Other than the major options discussed above, jrecreate also facilitates users with a few more options:
除了上面讨论的主要选项外,jrecreate还为用户提供了一些其他选项。
- ––help: displays summary of command line options for jrecreate tool
- ––debug: creates JRE that has debug support
- ––keep-debug-info: keeps the debug information from class and unsigned JAR files
- ––dry-run: performs a dry run without actually creating the JRE
- ––no-compression: creates a JRE with unsigned JAR files in uncompressed format
- ––verbose: displays verbose output for all jrecreate commands
4. Conclusion
4.总结
In this tutorial, we learned the basics of EJDK, and how the jrecreate tool is used to generate platform-specific JREs.
在本教程中,我们学习了EJDK的基础知识,以及如何使用jrecreate工具来生成特定平台的JRE。