Tag Archives: javafx

javafx 在netbeans中 打包

打包就是生成和在相关系统下的安装包。比如说生成ubuntu下的deb安装包,redhat/centos下的rpm安装包,windows下的安装程序。 系统要求:

  1. jdk > 1.7.40或者需要有javafx 环境
  2. netbeans

大概步骤如下:

  1. 创建javafxFXML 程序或者普通的javafx程序
  2. 右键属性选择,Build -> Deployment, Enable Native Packaging

完整的步骤看下面的截图:

1. 创建完项目之后的目录

2. 文件目录
3. 选中项目之后右键
4. 启用 native packaging
5. 打包
6. 打包的程序:
7. 如果的程序想要自己的项目图标,可以在这个目录设置。 关于这个目录的更多详情,请参考命令javafxpackager。这个命令会生成一些默认的打包设置。参考文章http://php-yhjhoo.rhcloud.com/archives/1141.html , 查看一些输出你就会明白的差不多了

JavaFX 程序打包命令javafxpackager

完整命令为

javafxpackager -deploy -native -outdir dist -outfile VOXPlayer -srcdir dist -srcfiles VOXPlayer.jar -appclass javafxapplication1.JavaFXApplication1

该命令在netbeans 项目下面执行,VOXPlayer 是我的项目名

 

启用verbose 之后的效果

javalinux@javalinux-Latitude-E6430:~$ cd NetBeansProjects/VOXPlayer/
javalinux@javalinux-Latitude-E6430:~/NetBeansProjects/VOXPlayer$ javafxpackager -deploy -native -outdir dist -outfile VOXPlayer -srcdir dist -srcfiles VOXPlayer.jar -appclass javafxapplication1.JavaFXApplication1 -verbose
Skip jar copy to itself: VOXPlayer.jar
Using base JDK at: /opt/java/jdk1.7.0_40/jre
Looking for bundlers for type=ALL format=any
Running [rpmbuild, --version]
Running [dpkg-deb, --version]
Creating app bundle: /home/javalinux/NetBeansProjects/VOXPlayer/dist/bundles/JavaFXApplication1
At least one type of shortcut is required. Enabling menu shortcut.
  Using default package resource [RPM spec file] (add package/linux/JavaFXApplication1.spec to the class path to customize)
  Using default package resource [Menu shortcut descriptor] (add package/linux/JavaFXApplication1.desktop to the class path to customize)
  Using default package resource [menu icon] (add package/linux/JavaFXApplication1.png to the class path to customize)
Generating RPM for installer to: /home/javalinux/NetBeansProjects/VOXPlayer/dist/bundles
Running [rpmbuild, -bb, /tmp/build7112394828429233989.fxbundler/images/linux-rpm.image/JavaFXApplication1.spec, --define, %_sourcedir /tmp/build7112394828429233989.fxbundler/images/linux-rpm.image, --define, %_rpmdir /home/javalinux/NetBeansProjects/VOXPlayer/dist/bundles, --define, %_topdir /tmp/build7112394828429233989.fxbundler/rmpbuildroot] in /tmp/build7112394828429233989.fxbundler/images/linux-rpm.image
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.l6znL6
+ umask 022
+ cd /tmp/build7112394828429233989.fxbundler/rmpbuildroot/BUILD
+ exit 0
Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.vStV1h
+ umask 022
+ cd /tmp/build7112394828429233989.fxbundler/rmpbuildroot/BUILD
+ exit 0
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.WuLPit
+ umask 022
+ cd /tmp/build7112394828429233989.fxbundler/rmpbuildroot/BUILD
+ rm -rf /tmp/build7112394828429233989.fxbundler/rmpbuildroot/BUILDROOT/JavaFXApplication1-1.0-1.x86_64
+ mkdir -p /tmp/build7112394828429233989.fxbundler/rmpbuildroot/BUILDROOT/JavaFXApplication1-1.0-1.x86_64/opt
+ cp -r /tmp/build7112394828429233989.fxbundler/images/linux-rpm.image/JavaFXApplication1 /tmp/build7112394828429233989.fxbundler/rmpbuildroot/BUILDROOT/JavaFXApplication1-1.0-1.x86_64/opt
+ /usr/lib/rpm/brp-compress
+ /usr/lib/rpm/brp-strip /usr/bin/strip
+ /usr/lib/rpm/brp-strip-static-archive /usr/bin/strip
+ /usr/lib/rpm/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump
Processing files: JavaFXApplication1-1.0-1.x86_64
Provides: JavaFXApplication1 JavaFXApplication1 = 1.0-1 JavaFXApplication1(x86-64) = 1.0-1
Requires(interp): /bin/sh /bin/sh
Requires(rpmlib): rpmlib(PayloadFilesHavePrefix) <= 4.0-1 rpmlib(CompressedFileNames) <= 3.0.4-1
Requires(post): /bin/sh
Requires(preun): /bin/sh
Checking for unpackaged file(s): /usr/lib/rpm/check-files /tmp/build7112394828429233989.fxbundler/rmpbuildroot/BUILDROOT/JavaFXApplication1-1.0-1.x86_64
Wrote: /home/javalinux/NetBeansProjects/VOXPlayer/dist/bundles/JavaFXApplication1-1.0-1.x86_64.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.ETITdQ
+ umask 022
+ cd /tmp/build7112394828429233989.fxbundler/rmpbuildroot/BUILD
+ exit 0
Package (.rpm) saved to: /home/javalinux/NetBeansProjects/VOXPlayer/dist/bundles
  Config files are saved to /tmp/build7112394828429233989.fxbundler/linux. Use them to customize package.
At least one type of shortcut is required. Enabling menu shortcut.
  Using default package resource [DEB control file] (add package/linux/control to the class path to customize)
  Using default package resource [DEB postinstall script] (add package/linux/postinst to the class path to customize)
  Using default package resource [DEB postinstall script] (add package/linux/postrm to the class path to customize)
  Using default package resource [DEB copyright file] (add package/linux/copyright to the class path to customize)
  Using default package resource [Menu shortcut descriptor] (add package/linux/JavaFXApplication1.desktop to the class path to customize)
  Using default package resource [menu icon] (add package/linux/JavaFXApplication1.png to the class path to customize)
Generating DEB for installer to: /home/javalinux/NetBeansProjects/VOXPlayer/dist/bundles/JavaFXApplication1-1.0.deb
Running [dpkg-deb, -b, JavaFXApplication1-1.0, /home/javalinux/NetBeansProjects/VOXPlayer/dist/bundles/JavaFXApplication1-1.0.deb] in /tmp/build7112394828429233989.fxbundler/images/linux-deb.image
dpkg-deb: building package `javafxapplication1' in `/home/javalinux/NetBeansProjects/VOXPlayer/dist/bundles/JavaFXApplication1-1.0.deb'.
Package (.deb) saved to: /home/javalinux/NetBeansProjects/VOXPlayer/dist/bundles/JavaFXApplication1-1.0.deb
  Config files are saved to /tmp/build7112394828429233989.fxbundler/linux. Use them to customize package.

JavaFX开发环境搭建

jdk自从1.7.40之后就集成的javaFX,看过几个例子之后还是很值得研究一下的。比起之前javaFX2.0的时候只支持windows 和mac,还是很开心的。因为我工作在linux和mac下面。

开发环境的搭建还是很简单的,不过目前选择不是很多,喜欢eclipse的同学可能要失望了,因为目前eclipse的支持不是很好。

我选择使用netbeans,总体步骤如下,如何安装请参考官方文档。

1,下载jdk , 要是1.7.40之后的版本,不然你要自己手动搭建javafx的运行环境
2,下载netbeans7.4
3,下载JavaFX Scene Builder http://www.oracle.com/technetwork/java/javafx/tools/index.html

最后一步要提醒的是创建javaFX项目的时候要选择JavaFX -> JavaFX FXML Application. 

附上插图两个: