Table of Contents
Syntax for using JEP package tools
How to use JEP package tool
Different ways to use attributes in Servlets
Method 1: Pack only one JAR file
Method 2: Pack multiple files into one directory
Method 3: Generate executable files for multiple platforms
JEP软件包工具的高级功能
创建自定义启动画面
签署包裹
合并 JVM 选择
结论
Home Java javaTutorial JEP package tool in Java

JEP package tool in Java

Sep 14, 2023 pm 05:21 PM
jep (java enhancement proposal) package tool

JEP package tool in Java

JEP, or Java Enhancement Proposal, are ideas for enhancing the Java platform. The JEP packaging tool is one such improvement that enables programmers to package Java programs into native executable files.

Developers can create native executables from Java programs by implementing the JEP Package Tool. Doing so gives these executables independence, eliminating dependence on the Java Virtual Machine (JVM) or other related software components. The emergence of this powerful tool started with Java 14, where it was introduced as an experimental feature.

Syntax for using JEP package tools

The syntax of the JEP package tools is easy to read and understand. Use JEP packaging tools. JDK 14 must be installed on your computer. Since this tool works through command line. Using it requires opening a terminal window or command prompt. This is the syntax for the JEP package tool -

jpackage [options]
Copy after login

The [options] field provides various parameters that you can use to modify the behavior of the JEP Package Tool. Optional and required options can be divided into two groups.

The options are as follows:

  • --name - The name of the package.

  • --input - The input directory containing the application files.

  • --main-jar − The name of the main JAR file.

  • --main-class − The name of the main class.

  • --type − Type of package (for example, exe, msi, deb, rpm).

  • --output − The name of the output file.

  • --vendor − The name of the vendor.

  • --copyright - Copyright statement.

  • --description - Description.

  • --resource-dir - Directory containing resources.

How to use JEP package tool

Follow the following steps to use the JEP packaging tool -

  • Step 1 - Install Java 14 or later

    The only requirement to use the JEP Package Tool is to install Java 14 or later. Therefore, if your device lacks this version of the Java software installed; it must be installed to access the tool.

  • Step 2 − Create a Java application

    In order to package a Java application as a local executable, create it. You can use non-modular applications or modular applications.

  • Step 3 - Compile the application

    Compile the program using the Java compiler

  • Step 4 - Create package

    Once the program is built, you can use the JEP Package tool to generate a native executable package. In order to achieve this, you must provide the name of the module and the location of the output file.

    The following is an example command to use the JEP Package tool to generate a native executable package -

jpackage --name MyApplication --input target/modules --main-jar MyApp.jar --main-class com.example.MyApp --type exe --output MyApplication.exe
Copy after login

For this particular example, the software used bears the name "MyApplication" and operates through a central JAR file appropriately titled "MyApp.jar". Access to data input can be found in the specified directory labeled "target/modules". Additionally, the name of the main class component that the program operates on is "com.example.MyApp". The final product generated using such a process will have relevant information in an output file labeled "MyApplication.exe", which is designed within the scope of a package structure designated as an executable ("exe") format.

Different ways to use attributes in Servlets

There are several ways to use the JEP packaging tool, depending on the specific requirements of your application.

Method 1: Pack only one JAR file

If your program consists of just a JAR file, then the JEP package tool is your best choice, allowing you to generate a self-sufficient executable file. especially. This executable does not require a different JRE to be installed on any machine to run. For example -

jpackage --input /path/to/myapp.jar --main-jar myapp.jar
Copy after login

Use this command to generate an autonomous executable file. It will generate a file called myapp which can be easily executed on any computer.

Method 2: Pack multiple files into one directory

Developers dealing with multiple distributed resources and configuration files or different libraries should choose the JEP package tool, which provides an efficient solution. With this tool, it is possible to generate an all-inclusive executable package that contains all necessary content.

jpackage --input /path/to/myapp --main-jar myapp.jar
Copy after login

This command will create a self-contained executable file named myapp that contains all files in the /path/to/myapp directory.

Method 3: Generate executable files for multiple platforms

To create a platform-specific executable file, such as an EXE file for Windows or a DMG file for macOS, you can take advantage of the JEP Package Tool's --type option. Here are some command examples -

jpackage --input /path/to/myapp --main-jar myapp.jar --type exe
Copy after login

This particular command has the ability to generate Myapp.exe - a completely self-contained and highly adaptable executable created specifically for use in a Windows environment.

jpackage --input /path/to/myapp --main-jar myapp.jar --type dmg
Copy after login

This command will generate a self-contained executable file Myapp.dmg that can be executed on macOS.

JEP软件包工具的高级功能

此外,JEP 包工具还提供了许多复杂的功能,可用于进一步定制包。这是一些插图 -

创建自定义启动画面

要为您的程序提供独特的启动屏幕,请使用 --splash 选项。命令示例如下 -

jpackage --input /path/to/myapp --main-jar myapp.jar --splash splash.png
Copy after login

此命令将生成一个独立的可执行文件,该文件具有名为splash.png的独特启动屏幕。

签署包裹

要使用证书对包进行签名,请使用 --sign 选项。命令示例如下 -

jpackage --input /path/to/myapp --main-jar myapp.jar --sign mycert
Copy after login

该程序将生成一个独立的可执行文件,该文件已签名并具有一个名为 mycert 的证书,名为 myapp。

合并 JVM 选择

启动程序时,您可以使用 --java-options 选项包含 JVM 参数。命令示例如下 -

jpackage --input /path/to/myapp --main-jar myapp.jar --java-options "-Xmx512m -Dmyprop=value"
Copy after login

JVM 选项 -Xmx512m 和 -Dmyprop=value 将包含在此命令生成的独立可执行文件中。

结论

JEP Package Tool 是一个强大的工具,可以让开发人员轻松地将 Java 程序打包成独立的可执行文件。 JEP 包工具可用于生成特定于特定平台的可执行文件,使用独特的启动屏幕和签名自定义包,并凭借其简单的语法和复杂的功能将 JVM 参数添加到应用程序的运行时。开发人员可以利用 JEP 包工具使 Java 应用程序更易于使用和访问,而无需安装单独的 JRE。

The above is the detailed content of JEP package tool in Java. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1669
14
PHP Tutorial
1273
29
C# Tutorial
1256
24
Is the company's security software causing the application to fail to run? How to troubleshoot and solve it? Is the company's security software causing the application to fail to run? How to troubleshoot and solve it? Apr 19, 2025 pm 04:51 PM

Troubleshooting and solutions to the company's security software that causes some applications to not function properly. Many companies will deploy security software in order to ensure internal network security. ...

How do I convert names to numbers to implement sorting and maintain consistency in groups? How do I convert names to numbers to implement sorting and maintain consistency in groups? Apr 19, 2025 pm 11:30 PM

Solutions to convert names to numbers to implement sorting In many application scenarios, users may need to sort in groups, especially in one...

How to simplify field mapping issues in system docking using MapStruct? How to simplify field mapping issues in system docking using MapStruct? Apr 19, 2025 pm 06:21 PM

Field mapping processing in system docking often encounters a difficult problem when performing system docking: how to effectively map the interface fields of system A...

How does IntelliJ IDEA identify the port number of a Spring Boot project without outputting a log? How does IntelliJ IDEA identify the port number of a Spring Boot project without outputting a log? Apr 19, 2025 pm 11:45 PM

Start Spring using IntelliJIDEAUltimate version...

How to elegantly obtain entity class variable names to build database query conditions? How to elegantly obtain entity class variable names to build database query conditions? Apr 19, 2025 pm 11:42 PM

When using MyBatis-Plus or other ORM frameworks for database operations, it is often necessary to construct query conditions based on the attribute name of the entity class. If you manually every time...

How to safely convert Java objects to arrays? How to safely convert Java objects to arrays? Apr 19, 2025 pm 11:33 PM

Conversion of Java Objects and Arrays: In-depth discussion of the risks and correct methods of cast type conversion Many Java beginners will encounter the conversion of an object into an array...

E-commerce platform SKU and SPU database design: How to take into account both user-defined attributes and attributeless products? E-commerce platform SKU and SPU database design: How to take into account both user-defined attributes and attributeless products? Apr 19, 2025 pm 11:27 PM

Detailed explanation of the design of SKU and SPU tables on e-commerce platforms This article will discuss the database design issues of SKU and SPU in e-commerce platforms, especially how to deal with user-defined sales...

How to use the Redis cache solution to efficiently realize the requirements of product ranking list? How to use the Redis cache solution to efficiently realize the requirements of product ranking list? Apr 19, 2025 pm 11:36 PM

How does the Redis caching solution realize the requirements of product ranking list? During the development process, we often need to deal with the requirements of rankings, such as displaying a...

See all articles