Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of generating exe File by java in jar package

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the "java jar package to generate exe files" related knowledge, in the actual case of the operation process, many people will encounter such a dilemma, and then let the editor lead you to learn how to deal with these situations! I hope you can read it carefully and be able to achieve something!

Related software: IDEA exe4j

JAVA Technology: maven SpringBoot jna

Application environment: windows7/10

MAVEN information

Net.java.dev.jna jna 5.6.0 org.springframework.boot spring-boot-starter-web org.projectlombok lombok 1.16.18 junit junit 4.12 Test org.junit.jupiter junit-jupiter RELEASE compile org.springframework.boot spring-boot-starter-test test org.junit.vintage junit-vintage-engine

First, MAVEN the SpringBoot project into a jar package.

@ RestControllerpublic class PublicApi {@ RequestMapping ("test") public ApiResponse testApi () {/ / DhScalePluNet is the name of the DLL file. This is the way to get the relative directory. The absolute directory can own Baidu CLibrary instance= Native.loadLibrary ("DhScalePluNet", CLibrary.class); int I = instance.dhSendPluDefault (); if (I! = 0) {ApiResponse result = new ApiResponse (ErrorCode.ERROR). Result.setResult (I); return result;} return new ApiResponse (ErrorCode.NO_ERROR);} @ RequestMapping ("test") public ApiResponse testApi () {String pa = new File (".") .getAbsolutePath (); pa = pa.substring (0, pa.length ()-1); pa = pa + "DhScalePluNet" Pa = pa.replaceAll ("/", "\"); log.info ("full path:" + pa); / / full path this path is the file path where exe is executed. After the application is packaged, dll | ini and other files will be in the same level directory as exe file CLibrary instance= Native.loadLibrary (pa, CLibrary.class); int I = instance.dhSendPluDefault () If (I! = 0) {ApiResponse result = new ApiResponse (ErrorCode.ERROR); result.setResult (I); return result;} return new ApiResponse (ErrorCode.NO_ERROR);}}

Project DLL file placed in the pit, generally can not read DLL, this time you need to put the DLL file into the win32-x86 directory to read. And my DLL is 32-bit DLL. 64 is still unknown.

After passing the local test, you can package it with the IDEA MAVEN plug-in.

The detailed usage tutorial for exe4j:

Then generate EXE file, your DLL file and EXE in the same directory level can be called normally.

This is the end of the introduction of "the method of java packing jar package to generate exe file". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report