IDEA playing Jar package and turn exe

Copyright: no copyright, reprint free to https://blog.csdn.net/MAOZEXIJR/article/details/88945545

First, the packaged jar 

1, the code symbol

Sample code, the actual demand: 

package com.cn;

import java.text.SimpleDateFormat;
import java.util.Date;

public class TimeLoop {

    public static void main(String[] args) {
        try {
            SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            while (true) {
                Thread.sleep(998);
                System.out.println(fmt.format(new Date()));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}

 

2, the configuration Artifacts 

(1)File → Project Structure → Project Settings → Artifacts → +→ JAR → From modules..

(2) Configuration Main Class 

(3)OK

 

3, the JAR

   

 

Two, jar turn exe

First View "exe4j Manual"

Exe present at the following parameters:

        Program type: " JAR in EXE " (Jar in Exe mode)

        Execute exe type: choose " Console the Application " (interactive console application)

        Exe median performed: according to the actual need to select 32 or 64

        JVM parameters: " -Dfile.encoding = UTF-. 8 "

        Entry type calling program: choose " Archive " (Archive Type)

        JRE addressing: selected from the " Directory " (relative path), as FIG.

 

When SpringBoot project played JAR packages do exe, class routing  " org.springframework.boot.loader.JarLauncher "

Rather than from the main class defined path, as shown in " com.baidu.cloud.application "

 

Third, the generated files

 

 

 

Guess you like

Origin blog.csdn.net/MAOZEXIJR/article/details/88945545