OSX上命令行的Javapackager工具?

OSX上命令行的Javapackager工具?

问题描述:

javapackager和javafxpackager似乎在我的命令行中无法识别。即使我安装了最新的1.8 SDK,它们也不会显示在终端中。 (即使'echo $ JAVA_HOME'似乎也是空白,尽管java -version似乎工作得很好。)

javapackager and javafxpackager don't seem to be recognised on the command line for me. They don't show up in the terminal, even after I installed the latest 1.8 SDK. (Even 'echo $JAVA_HOME' seems to be drawing a blank, though java -version seems to work fine.)

如果我查看/ Library / Java / JavaVirtualMachines / jdk1.8.0_91.jdk / Contents / Home / bin /我可以看到javapackager和javafxpackager工具存在,但如果我按照/ usr / libexec / java_home回到它的原点/System/Library/Frameworks/JavaVM.framework/版本/ A /命令/,没有它们的迹象。

If I look under /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/bin/ I can see the javapackager and javafxpackager tools are present, but if I follow /usr/libexec/java_home back to it's origin in /System/Library/Frameworks/JavaVM.framework/Versions/A/Commands/ , there's no sign of them.

我能找到的关于这个主题的唯一其他讨论是大约一年的博客文章和邮件列表半回:
https:/ /devreboot.wordpress.com/2014/11/26/java-desktop-app-packaging-automation/
http://lists.apple.com/archives/java-dev/2015/Nov/msg00009.html

The only other discussions I could find on the subject were a blog post and mailing list from about a year and a half back: https://devreboot.wordpress.com/2014/11/26/java-desktop-app-packaging-automation/ http://lists.apple.com/archives/java-dev/2015/Nov/msg00009.html

我意识到OSX没有附带java'默认情况下'已经有一段时间了,但这就是为什么我希望将我的应用程序作为一个独立的软件包与它自己的VM一起发布。更新我的bash配置文件以明确指向该工具是否是标准程序?我的个人设置有什么不妥之处,或者OSX上的工具支持是否有一些差距?

I realise OSX hasn't come with java 'by default' for some time, but that's kinda why I was hoping to release my application as a self-contained bundle with it's own VM. Would it be standard procedure to update my bash profile to point at the tool explicitly? Is there something screwy about my personal setup, or is there some gap in the tool support on OSX?



PS:我意识到有一个更老的关于这个问题的主题如下:
部署JavaFX应用程序,创建JAR和自包含应用程序以及本机安装程序的最佳方式是什么?


PS: I realise there's an older thread on this subject below: What is the best way to deploy JavaFX application, create JAR and self-contained applications and native installers

然而,这描述了javapackager作为.jar文件,无论我有什么,似乎都不是.jar文件。我对它应该用它做什么感到困惑。

However, that describes javapackager as a .jar file, and whatever I've got doesn't seem to be a .jar file. I'm legitimately confused about what I'm supposed to do with it.

编辑:感谢大家的提示 - 我想我有足够的信息可以继续现在。

Thanks to everyone for the tips- I think I have enough info to go on for now.

你可以试试这个从OS X命令行构建,打包和运行Java客户端应用程序上的测试安装的要点。不能保证它对你有用,这只是我很久以前为个人发展目的而掀起的。但是,其中的信息可能有助于从命令行解析打包工具位置以及执行其他打包相关功能。

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.

查找(和使用) javapackager 的关键部分是:

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

注意,上面是打包a Swing应用程序。打包JavaFX应用程序将对打包器使用稍微不同的命令行选项。

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

从命令行脚本执行此操作绝对是旧学校,通常 maven 或gradle。

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


我个人的偏好是只使用Ant,但我想这只是稍微不那么老了吗?

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

是的,并不是说有什么不妥。 使用Ant打包Java客户端应用程序的文档由Oracle提供。

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