eclipse will be packaged into a jar project running in linux

Recently because the project needs to do a few plug-ins for data transmission, the project involves the packaging operation, in the record about this issue and steps packaging in which it occurs.

1. First Right project folder, click on the export, the following pop-up selection box, jar in which you enter a search and select JAR flie click next.

2. Select the folder you want to pack, check here as long as you need to compile the java files on it, the following JAR file to save path after packaging and jar name, choose the good click next.

3. The following chart, click next.

4. The following diagram, Main class entrance path for the project, click on the back of the inlet path selection item button, choose a good click finish to finish packing.

After packed several issues need attention:

1.MANIFEST.MF documents need to be replaced according to their own writing projects, modify MANIFEST.MF file requires strict adherence to standards of writing, the first acts of Manifest-Version: 1.0 second acts Class -Path: xxx.jar (dependent jar) the third line Main-Class: the project path entrance, behind each colon needs to have a space, the end of each line without spaces, Main-Class: entrance path behind the project needs to play two line feed, if a plurality of dependent jar, after the completion of writing each of a space to write a jar, each line can not exceed 72 characters, if a write line for each jar, then each row begins two spaces.

 

2. 使用eclipse将项目打包后,项目中实际调取的依赖和文件等路径一般需要和项目的jar存放到同一级目录,否则会出现ClassNotFound等异常,放在同一级目录也方便后面根据需求修改配置文件。

3.编译好的jar可以用java -jar xxx.jar运行,这种运行方式会在命令行或linux服务器上显示启动和项目中的打印信息,当使用Ctrl+C退出时,jar的运行也会终止。

一般使用nohup命令运行项目:nohup java -jar xxx.jar >/dev/null &

这种方式运行jar在使用Ctrl+C退出时,jar的运行不会被终止,同时命令行或linux服务器不会显示启动和项目中的打印信息,nohup.out文件也不会有输入信息,此时如果想要查看项目运行信息,可以使用log4j输出日志文件进行查看。
摘自:https://blog.csdn.net/qq_36173194/article/details/82842531

Guess you like

Origin www.cnblogs.com/manmanchanglu/p/11426742.html