Javapackager tool from command-line on OSX?

戏子无情 提交于 2019-12-07 07:25:36

You could try this gist for building, packaging and running a test install on Java client apps from the OS X command line. No guarantees it will work for you, it was just something I whipped up for personal development purposes a long time ago. But, the info in there may help in resolving packager tool locations from the command line and also in performing other packaging related functions.

The key part for locating (and using) the javapackager is:

# select java version
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
$JAVA_HOME/bin/java -version
...
# make an executable jar file
$JAVA_HOME/bin/javapackager -createjar -srcdir . -appclass start.HelloWorldSwing -srcfiles HelloWorldSwing.jar -outdir . -outfile HelloWorld.jar

# package the jar and java runtime as a native application with installer
$JAVA_HOME/bin/javapackager -deploy -srcdir . -srcfiles HelloWorld.jar -outdir . -outfile HelloWorld -appclass start.HelloWorldSwing -native -name HelloWorld

Note, the above is for packaging a Swing application. Packaging a JavaFX application will use slightly different command line options for the packager.

Doing things this way from command line scripts is decidedly old school, usually maven or gradle is used.

My personal preference would be to just use Ant, but I guess that's only slightly less old-school?

Yes, not that there is anything wrong with that. Documentation on using Ant to package java client applications is provided by Oracle.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!