15
Launch JavaFX Application JAR by Double Clicking The 8th JavaFX User Goup Seminar on 2012-11-30 Toru Takahashi (@boochnich)

Launch JavaFX application JAR by double clicking

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Launch JavaFX Application JAR by Double Clicking

The 8th JavaFX User Goup Seminar

on 2012-11-30

Toru Takahashi (boochnich)

About Toru Twitter boochnich

blog httpdhatenanejptorutk bull Java GUI Programming Experience

ndash in jdk10 age AWT

ndash in jdk11 age AWT Netscape IFC and Swing

ndash in jdk12 age and after Swing Java2D (Java3D)

bull Java Community Activity ndash Representative of Java Reading Circle in Japan

httpwwwjavareadingcombof

Agenda

bull JavaFX 223 in the JDK 7u9

bull Building JavaFX application with NetBeans IDE

bull Creating an executable JAR with command

bull (optional) creating OS native installer

JavaFX 223 in the JDK 7u9

CyenProgram FilesyenJavayenjdk170 (Case of Windows OS)

+-- bin

| +-- javafxpackagerexe

+-- jre

| +-- lib

| +-- javafxproperties

| +-- jfxrtjar

+-- lib

+-- ant-javafxjar

+-- javafx-docletjar

(Note Not all JavaFX files are described)

Java FX files are in JDKrsquos directory tree

JavaFX application with NetBeans (15)

bull In NetBeans select New project ndash JavaFX Application templates are generated

bull Build and execute on NetBeans

httpjanetbeansorgnekobean

JavaFX application with NetBeans (25)

bull Double-click the jar file on a file explorer

ndash The program starts

bull lsquojava ndashjar foojarrsquo on command prompt

ndash It launches

JavaFX application with NetBeans (35)

bull Compile the source file and create jar gtjavac -cp ldquoCyenProgram Filesyenjavayenjdk170yenjreyenlibyenjfxrtjarldquo -d buildyenclasses -encoding UTF-8 srcyenhellojjfxugyenHelloJjfxugjava gtjar cvfm Hellojar hellomf -C buildyenclasses added manifest adding hellojjfxug(in = 0) (out= 0)(stored 0) adding hellojjfxugHelloJjfxug$1class(in = 1141) (out= 605)(deflated 46) adding hellojjfxugHelloJjfxugclass(in = 1740) (out= 981)(deflated 43) adding hellojjfxugHelloJjfxugcss(in = 302) (out= 214)(deflated 29)

gtjava ndashjar Hellojar Exception in thread main javalangNoClassDefFoundError javafxapp licationApplication at javalangClassLoaderdefineClass1(Native Method) at javalangClassLoaderdefineClass(ClassLoaderjava791)

Oh error has occurred missing classpath

JavaFX application with NetBeans (45)

bull Whatrsquos the difference between NetBeans and me

ndash Comparing with the jar file generated by NetBeans

comjavafxmainMain$1class comjavafxmainMain$2class comjavafxmainMainclass comjavafxmainNoJavaFXFallbackclass

Manifest-Version 10 JavaFX-Version 22 implementation-vendor torutk implementation-title HelloJjfxug implementation-version 10 JavaFX-Application-Class hellojjfxugHelloJjfxug JavaFX-Class-Path HelloJjfxugjar Created-By JavaFX Packager Main-Class comjavafxmainMain

These classes are only included in the jar file generated by NetBeans

MANIFESTMF in the jar file generated by NetBeans

JavaFX application with NetBeans (55)

bull add -Djavafxverbose=true option and execute the jar file generated by NetBeans

gtjava -Djavafxverbose=true -jar distyenHelloJjfxugjar 1) Try existing classpath ===== URL list fileCworkHelloJjfxugdistHelloJjfxugjar ===== 2) Try javafxruntimepath property

3) Look for cobundled JavaFX [javahome=CyenProgram FilesyenJavayenjdk170yenjre ===== URL list fileCworkHelloJjfxugdistHelloJjfxugjar fileCProgram20FilesJavajdk170jrelibjfxrtjar fileCProgram20FilesJavajdk170jrelibdeployjar fileCProgram20FilesJavajdk170jrelibpluginjar fileCProgram20FilesJavajdk170jrelibjavawsjar ===== Try calling ClassforName(hellojjfxugHelloJjfxug) using classLoader = javanet

URLClassLoader6f404c51 found class class hellojjfxugHelloJjfxug

Creating an executable JAR with command

bull Use javafxpackager command to create executable jar for JavaFX application

gtjavafxpackager -createjar -nocss2bin -appclass hellojjfxugHelloJjfxug -srcdir buildyenclasses -outdir -outfile HelloJjfxug-01 gtjava ndashjar HelloJjfxug-01jar

Specify a class extends Application and has a main method

Specify a base directory to include a jar file Not java source files

Specify the name of jar file without extension name(jar)

javafxpackager command reference

httpdocsoraclecomjavafx2deploymentjavafxpackager001htm

Reference

bull Oracle Blogs [JavaFX] Native packaging for JavaFX bull httpsblogsoraclecomtalkingjavadeploymente

ntrynative_packaging_for_javafx

bull Oracle JavaFX Documents rdquoDeploying JavaFX Applicationsrdquo bull httpdocsoraclecomjavafx2deploymentjfxp

ub-deploymenthtm 55 Create the Main Application JAR File

Conclusion

bull JavaFX is not only GUI toolkit but also an application deployment toolkit

bull NetBeans IDE provides JavaFX deployment

bull JDK provides javafxpackager command Ant task

bull There is the e(fx)clipse plugin for eclipse user

(additional1) create MSI

bull javapackager can create a Windows MSI Installer

ndash Needs WiX(Windows Installer XML) Free

bull NetBeans 73 can create by native build

bull I introduced creating msi installer on my blog (Japanese only)

ndash httpdhatenanejptorutk20121119

(additinal2) Creating RPM

bull javapackager can create Linux RPM installer

ndash Needs rpmbuild command

bull NetBeans 73 can create by native build

bull May be create deb installer

(additional3) Note for sample program

To read a CSS file which is in the same directory with source file

Scene scene = new Scene(root 300 250) scenegetStylesheets()add( thisgetClass()getResource(HelloJjfxugcss)toExternalForm())

Sample CSS for specifying a font for Button class

button -fx-font-size 24 -fx-font-family Consolas sans-serif

About Toru Twitter boochnich

blog httpdhatenanejptorutk bull Java GUI Programming Experience

ndash in jdk10 age AWT

ndash in jdk11 age AWT Netscape IFC and Swing

ndash in jdk12 age and after Swing Java2D (Java3D)

bull Java Community Activity ndash Representative of Java Reading Circle in Japan

httpwwwjavareadingcombof

Agenda

bull JavaFX 223 in the JDK 7u9

bull Building JavaFX application with NetBeans IDE

bull Creating an executable JAR with command

bull (optional) creating OS native installer

JavaFX 223 in the JDK 7u9

CyenProgram FilesyenJavayenjdk170 (Case of Windows OS)

+-- bin

| +-- javafxpackagerexe

+-- jre

| +-- lib

| +-- javafxproperties

| +-- jfxrtjar

+-- lib

+-- ant-javafxjar

+-- javafx-docletjar

(Note Not all JavaFX files are described)

Java FX files are in JDKrsquos directory tree

JavaFX application with NetBeans (15)

bull In NetBeans select New project ndash JavaFX Application templates are generated

bull Build and execute on NetBeans

httpjanetbeansorgnekobean

JavaFX application with NetBeans (25)

bull Double-click the jar file on a file explorer

ndash The program starts

bull lsquojava ndashjar foojarrsquo on command prompt

ndash It launches

JavaFX application with NetBeans (35)

bull Compile the source file and create jar gtjavac -cp ldquoCyenProgram Filesyenjavayenjdk170yenjreyenlibyenjfxrtjarldquo -d buildyenclasses -encoding UTF-8 srcyenhellojjfxugyenHelloJjfxugjava gtjar cvfm Hellojar hellomf -C buildyenclasses added manifest adding hellojjfxug(in = 0) (out= 0)(stored 0) adding hellojjfxugHelloJjfxug$1class(in = 1141) (out= 605)(deflated 46) adding hellojjfxugHelloJjfxugclass(in = 1740) (out= 981)(deflated 43) adding hellojjfxugHelloJjfxugcss(in = 302) (out= 214)(deflated 29)

gtjava ndashjar Hellojar Exception in thread main javalangNoClassDefFoundError javafxapp licationApplication at javalangClassLoaderdefineClass1(Native Method) at javalangClassLoaderdefineClass(ClassLoaderjava791)

Oh error has occurred missing classpath

JavaFX application with NetBeans (45)

bull Whatrsquos the difference between NetBeans and me

ndash Comparing with the jar file generated by NetBeans

comjavafxmainMain$1class comjavafxmainMain$2class comjavafxmainMainclass comjavafxmainNoJavaFXFallbackclass

Manifest-Version 10 JavaFX-Version 22 implementation-vendor torutk implementation-title HelloJjfxug implementation-version 10 JavaFX-Application-Class hellojjfxugHelloJjfxug JavaFX-Class-Path HelloJjfxugjar Created-By JavaFX Packager Main-Class comjavafxmainMain

These classes are only included in the jar file generated by NetBeans

MANIFESTMF in the jar file generated by NetBeans

JavaFX application with NetBeans (55)

bull add -Djavafxverbose=true option and execute the jar file generated by NetBeans

gtjava -Djavafxverbose=true -jar distyenHelloJjfxugjar 1) Try existing classpath ===== URL list fileCworkHelloJjfxugdistHelloJjfxugjar ===== 2) Try javafxruntimepath property

3) Look for cobundled JavaFX [javahome=CyenProgram FilesyenJavayenjdk170yenjre ===== URL list fileCworkHelloJjfxugdistHelloJjfxugjar fileCProgram20FilesJavajdk170jrelibjfxrtjar fileCProgram20FilesJavajdk170jrelibdeployjar fileCProgram20FilesJavajdk170jrelibpluginjar fileCProgram20FilesJavajdk170jrelibjavawsjar ===== Try calling ClassforName(hellojjfxugHelloJjfxug) using classLoader = javanet

URLClassLoader6f404c51 found class class hellojjfxugHelloJjfxug

Creating an executable JAR with command

bull Use javafxpackager command to create executable jar for JavaFX application

gtjavafxpackager -createjar -nocss2bin -appclass hellojjfxugHelloJjfxug -srcdir buildyenclasses -outdir -outfile HelloJjfxug-01 gtjava ndashjar HelloJjfxug-01jar

Specify a class extends Application and has a main method

Specify a base directory to include a jar file Not java source files

Specify the name of jar file without extension name(jar)

javafxpackager command reference

httpdocsoraclecomjavafx2deploymentjavafxpackager001htm

Reference

bull Oracle Blogs [JavaFX] Native packaging for JavaFX bull httpsblogsoraclecomtalkingjavadeploymente

ntrynative_packaging_for_javafx

bull Oracle JavaFX Documents rdquoDeploying JavaFX Applicationsrdquo bull httpdocsoraclecomjavafx2deploymentjfxp

ub-deploymenthtm 55 Create the Main Application JAR File

Conclusion

bull JavaFX is not only GUI toolkit but also an application deployment toolkit

bull NetBeans IDE provides JavaFX deployment

bull JDK provides javafxpackager command Ant task

bull There is the e(fx)clipse plugin for eclipse user

(additional1) create MSI

bull javapackager can create a Windows MSI Installer

ndash Needs WiX(Windows Installer XML) Free

bull NetBeans 73 can create by native build

bull I introduced creating msi installer on my blog (Japanese only)

ndash httpdhatenanejptorutk20121119

(additinal2) Creating RPM

bull javapackager can create Linux RPM installer

ndash Needs rpmbuild command

bull NetBeans 73 can create by native build

bull May be create deb installer

(additional3) Note for sample program

To read a CSS file which is in the same directory with source file

Scene scene = new Scene(root 300 250) scenegetStylesheets()add( thisgetClass()getResource(HelloJjfxugcss)toExternalForm())

Sample CSS for specifying a font for Button class

button -fx-font-size 24 -fx-font-family Consolas sans-serif

Agenda

bull JavaFX 223 in the JDK 7u9

bull Building JavaFX application with NetBeans IDE

bull Creating an executable JAR with command

bull (optional) creating OS native installer

JavaFX 223 in the JDK 7u9

CyenProgram FilesyenJavayenjdk170 (Case of Windows OS)

+-- bin

| +-- javafxpackagerexe

+-- jre

| +-- lib

| +-- javafxproperties

| +-- jfxrtjar

+-- lib

+-- ant-javafxjar

+-- javafx-docletjar

(Note Not all JavaFX files are described)

Java FX files are in JDKrsquos directory tree

JavaFX application with NetBeans (15)

bull In NetBeans select New project ndash JavaFX Application templates are generated

bull Build and execute on NetBeans

httpjanetbeansorgnekobean

JavaFX application with NetBeans (25)

bull Double-click the jar file on a file explorer

ndash The program starts

bull lsquojava ndashjar foojarrsquo on command prompt

ndash It launches

JavaFX application with NetBeans (35)

bull Compile the source file and create jar gtjavac -cp ldquoCyenProgram Filesyenjavayenjdk170yenjreyenlibyenjfxrtjarldquo -d buildyenclasses -encoding UTF-8 srcyenhellojjfxugyenHelloJjfxugjava gtjar cvfm Hellojar hellomf -C buildyenclasses added manifest adding hellojjfxug(in = 0) (out= 0)(stored 0) adding hellojjfxugHelloJjfxug$1class(in = 1141) (out= 605)(deflated 46) adding hellojjfxugHelloJjfxugclass(in = 1740) (out= 981)(deflated 43) adding hellojjfxugHelloJjfxugcss(in = 302) (out= 214)(deflated 29)

gtjava ndashjar Hellojar Exception in thread main javalangNoClassDefFoundError javafxapp licationApplication at javalangClassLoaderdefineClass1(Native Method) at javalangClassLoaderdefineClass(ClassLoaderjava791)

Oh error has occurred missing classpath

JavaFX application with NetBeans (45)

bull Whatrsquos the difference between NetBeans and me

ndash Comparing with the jar file generated by NetBeans

comjavafxmainMain$1class comjavafxmainMain$2class comjavafxmainMainclass comjavafxmainNoJavaFXFallbackclass

Manifest-Version 10 JavaFX-Version 22 implementation-vendor torutk implementation-title HelloJjfxug implementation-version 10 JavaFX-Application-Class hellojjfxugHelloJjfxug JavaFX-Class-Path HelloJjfxugjar Created-By JavaFX Packager Main-Class comjavafxmainMain

These classes are only included in the jar file generated by NetBeans

MANIFESTMF in the jar file generated by NetBeans

JavaFX application with NetBeans (55)

bull add -Djavafxverbose=true option and execute the jar file generated by NetBeans

gtjava -Djavafxverbose=true -jar distyenHelloJjfxugjar 1) Try existing classpath ===== URL list fileCworkHelloJjfxugdistHelloJjfxugjar ===== 2) Try javafxruntimepath property

3) Look for cobundled JavaFX [javahome=CyenProgram FilesyenJavayenjdk170yenjre ===== URL list fileCworkHelloJjfxugdistHelloJjfxugjar fileCProgram20FilesJavajdk170jrelibjfxrtjar fileCProgram20FilesJavajdk170jrelibdeployjar fileCProgram20FilesJavajdk170jrelibpluginjar fileCProgram20FilesJavajdk170jrelibjavawsjar ===== Try calling ClassforName(hellojjfxugHelloJjfxug) using classLoader = javanet

URLClassLoader6f404c51 found class class hellojjfxugHelloJjfxug

Creating an executable JAR with command

bull Use javafxpackager command to create executable jar for JavaFX application

gtjavafxpackager -createjar -nocss2bin -appclass hellojjfxugHelloJjfxug -srcdir buildyenclasses -outdir -outfile HelloJjfxug-01 gtjava ndashjar HelloJjfxug-01jar

Specify a class extends Application and has a main method

Specify a base directory to include a jar file Not java source files

Specify the name of jar file without extension name(jar)

javafxpackager command reference

httpdocsoraclecomjavafx2deploymentjavafxpackager001htm

Reference

bull Oracle Blogs [JavaFX] Native packaging for JavaFX bull httpsblogsoraclecomtalkingjavadeploymente

ntrynative_packaging_for_javafx

bull Oracle JavaFX Documents rdquoDeploying JavaFX Applicationsrdquo bull httpdocsoraclecomjavafx2deploymentjfxp

ub-deploymenthtm 55 Create the Main Application JAR File

Conclusion

bull JavaFX is not only GUI toolkit but also an application deployment toolkit

bull NetBeans IDE provides JavaFX deployment

bull JDK provides javafxpackager command Ant task

bull There is the e(fx)clipse plugin for eclipse user

(additional1) create MSI

bull javapackager can create a Windows MSI Installer

ndash Needs WiX(Windows Installer XML) Free

bull NetBeans 73 can create by native build

bull I introduced creating msi installer on my blog (Japanese only)

ndash httpdhatenanejptorutk20121119

(additinal2) Creating RPM

bull javapackager can create Linux RPM installer

ndash Needs rpmbuild command

bull NetBeans 73 can create by native build

bull May be create deb installer

(additional3) Note for sample program

To read a CSS file which is in the same directory with source file

Scene scene = new Scene(root 300 250) scenegetStylesheets()add( thisgetClass()getResource(HelloJjfxugcss)toExternalForm())

Sample CSS for specifying a font for Button class

button -fx-font-size 24 -fx-font-family Consolas sans-serif

JavaFX 223 in the JDK 7u9

CyenProgram FilesyenJavayenjdk170 (Case of Windows OS)

+-- bin

| +-- javafxpackagerexe

+-- jre

| +-- lib

| +-- javafxproperties

| +-- jfxrtjar

+-- lib

+-- ant-javafxjar

+-- javafx-docletjar

(Note Not all JavaFX files are described)

Java FX files are in JDKrsquos directory tree

JavaFX application with NetBeans (15)

bull In NetBeans select New project ndash JavaFX Application templates are generated

bull Build and execute on NetBeans

httpjanetbeansorgnekobean

JavaFX application with NetBeans (25)

bull Double-click the jar file on a file explorer

ndash The program starts

bull lsquojava ndashjar foojarrsquo on command prompt

ndash It launches

JavaFX application with NetBeans (35)

bull Compile the source file and create jar gtjavac -cp ldquoCyenProgram Filesyenjavayenjdk170yenjreyenlibyenjfxrtjarldquo -d buildyenclasses -encoding UTF-8 srcyenhellojjfxugyenHelloJjfxugjava gtjar cvfm Hellojar hellomf -C buildyenclasses added manifest adding hellojjfxug(in = 0) (out= 0)(stored 0) adding hellojjfxugHelloJjfxug$1class(in = 1141) (out= 605)(deflated 46) adding hellojjfxugHelloJjfxugclass(in = 1740) (out= 981)(deflated 43) adding hellojjfxugHelloJjfxugcss(in = 302) (out= 214)(deflated 29)

gtjava ndashjar Hellojar Exception in thread main javalangNoClassDefFoundError javafxapp licationApplication at javalangClassLoaderdefineClass1(Native Method) at javalangClassLoaderdefineClass(ClassLoaderjava791)

Oh error has occurred missing classpath

JavaFX application with NetBeans (45)

bull Whatrsquos the difference between NetBeans and me

ndash Comparing with the jar file generated by NetBeans

comjavafxmainMain$1class comjavafxmainMain$2class comjavafxmainMainclass comjavafxmainNoJavaFXFallbackclass

Manifest-Version 10 JavaFX-Version 22 implementation-vendor torutk implementation-title HelloJjfxug implementation-version 10 JavaFX-Application-Class hellojjfxugHelloJjfxug JavaFX-Class-Path HelloJjfxugjar Created-By JavaFX Packager Main-Class comjavafxmainMain

These classes are only included in the jar file generated by NetBeans

MANIFESTMF in the jar file generated by NetBeans

JavaFX application with NetBeans (55)

bull add -Djavafxverbose=true option and execute the jar file generated by NetBeans

gtjava -Djavafxverbose=true -jar distyenHelloJjfxugjar 1) Try existing classpath ===== URL list fileCworkHelloJjfxugdistHelloJjfxugjar ===== 2) Try javafxruntimepath property

3) Look for cobundled JavaFX [javahome=CyenProgram FilesyenJavayenjdk170yenjre ===== URL list fileCworkHelloJjfxugdistHelloJjfxugjar fileCProgram20FilesJavajdk170jrelibjfxrtjar fileCProgram20FilesJavajdk170jrelibdeployjar fileCProgram20FilesJavajdk170jrelibpluginjar fileCProgram20FilesJavajdk170jrelibjavawsjar ===== Try calling ClassforName(hellojjfxugHelloJjfxug) using classLoader = javanet

URLClassLoader6f404c51 found class class hellojjfxugHelloJjfxug

Creating an executable JAR with command

bull Use javafxpackager command to create executable jar for JavaFX application

gtjavafxpackager -createjar -nocss2bin -appclass hellojjfxugHelloJjfxug -srcdir buildyenclasses -outdir -outfile HelloJjfxug-01 gtjava ndashjar HelloJjfxug-01jar

Specify a class extends Application and has a main method

Specify a base directory to include a jar file Not java source files

Specify the name of jar file without extension name(jar)

javafxpackager command reference

httpdocsoraclecomjavafx2deploymentjavafxpackager001htm

Reference

bull Oracle Blogs [JavaFX] Native packaging for JavaFX bull httpsblogsoraclecomtalkingjavadeploymente

ntrynative_packaging_for_javafx

bull Oracle JavaFX Documents rdquoDeploying JavaFX Applicationsrdquo bull httpdocsoraclecomjavafx2deploymentjfxp

ub-deploymenthtm 55 Create the Main Application JAR File

Conclusion

bull JavaFX is not only GUI toolkit but also an application deployment toolkit

bull NetBeans IDE provides JavaFX deployment

bull JDK provides javafxpackager command Ant task

bull There is the e(fx)clipse plugin for eclipse user

(additional1) create MSI

bull javapackager can create a Windows MSI Installer

ndash Needs WiX(Windows Installer XML) Free

bull NetBeans 73 can create by native build

bull I introduced creating msi installer on my blog (Japanese only)

ndash httpdhatenanejptorutk20121119

(additinal2) Creating RPM

bull javapackager can create Linux RPM installer

ndash Needs rpmbuild command

bull NetBeans 73 can create by native build

bull May be create deb installer

(additional3) Note for sample program

To read a CSS file which is in the same directory with source file

Scene scene = new Scene(root 300 250) scenegetStylesheets()add( thisgetClass()getResource(HelloJjfxugcss)toExternalForm())

Sample CSS for specifying a font for Button class

button -fx-font-size 24 -fx-font-family Consolas sans-serif

JavaFX application with NetBeans (15)

bull In NetBeans select New project ndash JavaFX Application templates are generated

bull Build and execute on NetBeans

httpjanetbeansorgnekobean

JavaFX application with NetBeans (25)

bull Double-click the jar file on a file explorer

ndash The program starts

bull lsquojava ndashjar foojarrsquo on command prompt

ndash It launches

JavaFX application with NetBeans (35)

bull Compile the source file and create jar gtjavac -cp ldquoCyenProgram Filesyenjavayenjdk170yenjreyenlibyenjfxrtjarldquo -d buildyenclasses -encoding UTF-8 srcyenhellojjfxugyenHelloJjfxugjava gtjar cvfm Hellojar hellomf -C buildyenclasses added manifest adding hellojjfxug(in = 0) (out= 0)(stored 0) adding hellojjfxugHelloJjfxug$1class(in = 1141) (out= 605)(deflated 46) adding hellojjfxugHelloJjfxugclass(in = 1740) (out= 981)(deflated 43) adding hellojjfxugHelloJjfxugcss(in = 302) (out= 214)(deflated 29)

gtjava ndashjar Hellojar Exception in thread main javalangNoClassDefFoundError javafxapp licationApplication at javalangClassLoaderdefineClass1(Native Method) at javalangClassLoaderdefineClass(ClassLoaderjava791)

Oh error has occurred missing classpath

JavaFX application with NetBeans (45)

bull Whatrsquos the difference between NetBeans and me

ndash Comparing with the jar file generated by NetBeans

comjavafxmainMain$1class comjavafxmainMain$2class comjavafxmainMainclass comjavafxmainNoJavaFXFallbackclass

Manifest-Version 10 JavaFX-Version 22 implementation-vendor torutk implementation-title HelloJjfxug implementation-version 10 JavaFX-Application-Class hellojjfxugHelloJjfxug JavaFX-Class-Path HelloJjfxugjar Created-By JavaFX Packager Main-Class comjavafxmainMain

These classes are only included in the jar file generated by NetBeans

MANIFESTMF in the jar file generated by NetBeans

JavaFX application with NetBeans (55)

bull add -Djavafxverbose=true option and execute the jar file generated by NetBeans

gtjava -Djavafxverbose=true -jar distyenHelloJjfxugjar 1) Try existing classpath ===== URL list fileCworkHelloJjfxugdistHelloJjfxugjar ===== 2) Try javafxruntimepath property

3) Look for cobundled JavaFX [javahome=CyenProgram FilesyenJavayenjdk170yenjre ===== URL list fileCworkHelloJjfxugdistHelloJjfxugjar fileCProgram20FilesJavajdk170jrelibjfxrtjar fileCProgram20FilesJavajdk170jrelibdeployjar fileCProgram20FilesJavajdk170jrelibpluginjar fileCProgram20FilesJavajdk170jrelibjavawsjar ===== Try calling ClassforName(hellojjfxugHelloJjfxug) using classLoader = javanet

URLClassLoader6f404c51 found class class hellojjfxugHelloJjfxug

Creating an executable JAR with command

bull Use javafxpackager command to create executable jar for JavaFX application

gtjavafxpackager -createjar -nocss2bin -appclass hellojjfxugHelloJjfxug -srcdir buildyenclasses -outdir -outfile HelloJjfxug-01 gtjava ndashjar HelloJjfxug-01jar

Specify a class extends Application and has a main method

Specify a base directory to include a jar file Not java source files

Specify the name of jar file without extension name(jar)

javafxpackager command reference

httpdocsoraclecomjavafx2deploymentjavafxpackager001htm

Reference

bull Oracle Blogs [JavaFX] Native packaging for JavaFX bull httpsblogsoraclecomtalkingjavadeploymente

ntrynative_packaging_for_javafx

bull Oracle JavaFX Documents rdquoDeploying JavaFX Applicationsrdquo bull httpdocsoraclecomjavafx2deploymentjfxp

ub-deploymenthtm 55 Create the Main Application JAR File

Conclusion

bull JavaFX is not only GUI toolkit but also an application deployment toolkit

bull NetBeans IDE provides JavaFX deployment

bull JDK provides javafxpackager command Ant task

bull There is the e(fx)clipse plugin for eclipse user

(additional1) create MSI

bull javapackager can create a Windows MSI Installer

ndash Needs WiX(Windows Installer XML) Free

bull NetBeans 73 can create by native build

bull I introduced creating msi installer on my blog (Japanese only)

ndash httpdhatenanejptorutk20121119

(additinal2) Creating RPM

bull javapackager can create Linux RPM installer

ndash Needs rpmbuild command

bull NetBeans 73 can create by native build

bull May be create deb installer

(additional3) Note for sample program

To read a CSS file which is in the same directory with source file

Scene scene = new Scene(root 300 250) scenegetStylesheets()add( thisgetClass()getResource(HelloJjfxugcss)toExternalForm())

Sample CSS for specifying a font for Button class

button -fx-font-size 24 -fx-font-family Consolas sans-serif

JavaFX application with NetBeans (25)

bull Double-click the jar file on a file explorer

ndash The program starts

bull lsquojava ndashjar foojarrsquo on command prompt

ndash It launches

JavaFX application with NetBeans (35)

bull Compile the source file and create jar gtjavac -cp ldquoCyenProgram Filesyenjavayenjdk170yenjreyenlibyenjfxrtjarldquo -d buildyenclasses -encoding UTF-8 srcyenhellojjfxugyenHelloJjfxugjava gtjar cvfm Hellojar hellomf -C buildyenclasses added manifest adding hellojjfxug(in = 0) (out= 0)(stored 0) adding hellojjfxugHelloJjfxug$1class(in = 1141) (out= 605)(deflated 46) adding hellojjfxugHelloJjfxugclass(in = 1740) (out= 981)(deflated 43) adding hellojjfxugHelloJjfxugcss(in = 302) (out= 214)(deflated 29)

gtjava ndashjar Hellojar Exception in thread main javalangNoClassDefFoundError javafxapp licationApplication at javalangClassLoaderdefineClass1(Native Method) at javalangClassLoaderdefineClass(ClassLoaderjava791)

Oh error has occurred missing classpath

JavaFX application with NetBeans (45)

bull Whatrsquos the difference between NetBeans and me

ndash Comparing with the jar file generated by NetBeans

comjavafxmainMain$1class comjavafxmainMain$2class comjavafxmainMainclass comjavafxmainNoJavaFXFallbackclass

Manifest-Version 10 JavaFX-Version 22 implementation-vendor torutk implementation-title HelloJjfxug implementation-version 10 JavaFX-Application-Class hellojjfxugHelloJjfxug JavaFX-Class-Path HelloJjfxugjar Created-By JavaFX Packager Main-Class comjavafxmainMain

These classes are only included in the jar file generated by NetBeans

MANIFESTMF in the jar file generated by NetBeans

JavaFX application with NetBeans (55)

bull add -Djavafxverbose=true option and execute the jar file generated by NetBeans

gtjava -Djavafxverbose=true -jar distyenHelloJjfxugjar 1) Try existing classpath ===== URL list fileCworkHelloJjfxugdistHelloJjfxugjar ===== 2) Try javafxruntimepath property

3) Look for cobundled JavaFX [javahome=CyenProgram FilesyenJavayenjdk170yenjre ===== URL list fileCworkHelloJjfxugdistHelloJjfxugjar fileCProgram20FilesJavajdk170jrelibjfxrtjar fileCProgram20FilesJavajdk170jrelibdeployjar fileCProgram20FilesJavajdk170jrelibpluginjar fileCProgram20FilesJavajdk170jrelibjavawsjar ===== Try calling ClassforName(hellojjfxugHelloJjfxug) using classLoader = javanet

URLClassLoader6f404c51 found class class hellojjfxugHelloJjfxug

Creating an executable JAR with command

bull Use javafxpackager command to create executable jar for JavaFX application

gtjavafxpackager -createjar -nocss2bin -appclass hellojjfxugHelloJjfxug -srcdir buildyenclasses -outdir -outfile HelloJjfxug-01 gtjava ndashjar HelloJjfxug-01jar

Specify a class extends Application and has a main method

Specify a base directory to include a jar file Not java source files

Specify the name of jar file without extension name(jar)

javafxpackager command reference

httpdocsoraclecomjavafx2deploymentjavafxpackager001htm

Reference

bull Oracle Blogs [JavaFX] Native packaging for JavaFX bull httpsblogsoraclecomtalkingjavadeploymente

ntrynative_packaging_for_javafx

bull Oracle JavaFX Documents rdquoDeploying JavaFX Applicationsrdquo bull httpdocsoraclecomjavafx2deploymentjfxp

ub-deploymenthtm 55 Create the Main Application JAR File

Conclusion

bull JavaFX is not only GUI toolkit but also an application deployment toolkit

bull NetBeans IDE provides JavaFX deployment

bull JDK provides javafxpackager command Ant task

bull There is the e(fx)clipse plugin for eclipse user

(additional1) create MSI

bull javapackager can create a Windows MSI Installer

ndash Needs WiX(Windows Installer XML) Free

bull NetBeans 73 can create by native build

bull I introduced creating msi installer on my blog (Japanese only)

ndash httpdhatenanejptorutk20121119

(additinal2) Creating RPM

bull javapackager can create Linux RPM installer

ndash Needs rpmbuild command

bull NetBeans 73 can create by native build

bull May be create deb installer

(additional3) Note for sample program

To read a CSS file which is in the same directory with source file

Scene scene = new Scene(root 300 250) scenegetStylesheets()add( thisgetClass()getResource(HelloJjfxugcss)toExternalForm())

Sample CSS for specifying a font for Button class

button -fx-font-size 24 -fx-font-family Consolas sans-serif

JavaFX application with NetBeans (35)

bull Compile the source file and create jar gtjavac -cp ldquoCyenProgram Filesyenjavayenjdk170yenjreyenlibyenjfxrtjarldquo -d buildyenclasses -encoding UTF-8 srcyenhellojjfxugyenHelloJjfxugjava gtjar cvfm Hellojar hellomf -C buildyenclasses added manifest adding hellojjfxug(in = 0) (out= 0)(stored 0) adding hellojjfxugHelloJjfxug$1class(in = 1141) (out= 605)(deflated 46) adding hellojjfxugHelloJjfxugclass(in = 1740) (out= 981)(deflated 43) adding hellojjfxugHelloJjfxugcss(in = 302) (out= 214)(deflated 29)

gtjava ndashjar Hellojar Exception in thread main javalangNoClassDefFoundError javafxapp licationApplication at javalangClassLoaderdefineClass1(Native Method) at javalangClassLoaderdefineClass(ClassLoaderjava791)

Oh error has occurred missing classpath

JavaFX application with NetBeans (45)

bull Whatrsquos the difference between NetBeans and me

ndash Comparing with the jar file generated by NetBeans

comjavafxmainMain$1class comjavafxmainMain$2class comjavafxmainMainclass comjavafxmainNoJavaFXFallbackclass

Manifest-Version 10 JavaFX-Version 22 implementation-vendor torutk implementation-title HelloJjfxug implementation-version 10 JavaFX-Application-Class hellojjfxugHelloJjfxug JavaFX-Class-Path HelloJjfxugjar Created-By JavaFX Packager Main-Class comjavafxmainMain

These classes are only included in the jar file generated by NetBeans

MANIFESTMF in the jar file generated by NetBeans

JavaFX application with NetBeans (55)

bull add -Djavafxverbose=true option and execute the jar file generated by NetBeans

gtjava -Djavafxverbose=true -jar distyenHelloJjfxugjar 1) Try existing classpath ===== URL list fileCworkHelloJjfxugdistHelloJjfxugjar ===== 2) Try javafxruntimepath property

3) Look for cobundled JavaFX [javahome=CyenProgram FilesyenJavayenjdk170yenjre ===== URL list fileCworkHelloJjfxugdistHelloJjfxugjar fileCProgram20FilesJavajdk170jrelibjfxrtjar fileCProgram20FilesJavajdk170jrelibdeployjar fileCProgram20FilesJavajdk170jrelibpluginjar fileCProgram20FilesJavajdk170jrelibjavawsjar ===== Try calling ClassforName(hellojjfxugHelloJjfxug) using classLoader = javanet

URLClassLoader6f404c51 found class class hellojjfxugHelloJjfxug

Creating an executable JAR with command

bull Use javafxpackager command to create executable jar for JavaFX application

gtjavafxpackager -createjar -nocss2bin -appclass hellojjfxugHelloJjfxug -srcdir buildyenclasses -outdir -outfile HelloJjfxug-01 gtjava ndashjar HelloJjfxug-01jar

Specify a class extends Application and has a main method

Specify a base directory to include a jar file Not java source files

Specify the name of jar file without extension name(jar)

javafxpackager command reference

httpdocsoraclecomjavafx2deploymentjavafxpackager001htm

Reference

bull Oracle Blogs [JavaFX] Native packaging for JavaFX bull httpsblogsoraclecomtalkingjavadeploymente

ntrynative_packaging_for_javafx

bull Oracle JavaFX Documents rdquoDeploying JavaFX Applicationsrdquo bull httpdocsoraclecomjavafx2deploymentjfxp

ub-deploymenthtm 55 Create the Main Application JAR File

Conclusion

bull JavaFX is not only GUI toolkit but also an application deployment toolkit

bull NetBeans IDE provides JavaFX deployment

bull JDK provides javafxpackager command Ant task

bull There is the e(fx)clipse plugin for eclipse user

(additional1) create MSI

bull javapackager can create a Windows MSI Installer

ndash Needs WiX(Windows Installer XML) Free

bull NetBeans 73 can create by native build

bull I introduced creating msi installer on my blog (Japanese only)

ndash httpdhatenanejptorutk20121119

(additinal2) Creating RPM

bull javapackager can create Linux RPM installer

ndash Needs rpmbuild command

bull NetBeans 73 can create by native build

bull May be create deb installer

(additional3) Note for sample program

To read a CSS file which is in the same directory with source file

Scene scene = new Scene(root 300 250) scenegetStylesheets()add( thisgetClass()getResource(HelloJjfxugcss)toExternalForm())

Sample CSS for specifying a font for Button class

button -fx-font-size 24 -fx-font-family Consolas sans-serif

JavaFX application with NetBeans (45)

bull Whatrsquos the difference between NetBeans and me

ndash Comparing with the jar file generated by NetBeans

comjavafxmainMain$1class comjavafxmainMain$2class comjavafxmainMainclass comjavafxmainNoJavaFXFallbackclass

Manifest-Version 10 JavaFX-Version 22 implementation-vendor torutk implementation-title HelloJjfxug implementation-version 10 JavaFX-Application-Class hellojjfxugHelloJjfxug JavaFX-Class-Path HelloJjfxugjar Created-By JavaFX Packager Main-Class comjavafxmainMain

These classes are only included in the jar file generated by NetBeans

MANIFESTMF in the jar file generated by NetBeans

JavaFX application with NetBeans (55)

bull add -Djavafxverbose=true option and execute the jar file generated by NetBeans

gtjava -Djavafxverbose=true -jar distyenHelloJjfxugjar 1) Try existing classpath ===== URL list fileCworkHelloJjfxugdistHelloJjfxugjar ===== 2) Try javafxruntimepath property

3) Look for cobundled JavaFX [javahome=CyenProgram FilesyenJavayenjdk170yenjre ===== URL list fileCworkHelloJjfxugdistHelloJjfxugjar fileCProgram20FilesJavajdk170jrelibjfxrtjar fileCProgram20FilesJavajdk170jrelibdeployjar fileCProgram20FilesJavajdk170jrelibpluginjar fileCProgram20FilesJavajdk170jrelibjavawsjar ===== Try calling ClassforName(hellojjfxugHelloJjfxug) using classLoader = javanet

URLClassLoader6f404c51 found class class hellojjfxugHelloJjfxug

Creating an executable JAR with command

bull Use javafxpackager command to create executable jar for JavaFX application

gtjavafxpackager -createjar -nocss2bin -appclass hellojjfxugHelloJjfxug -srcdir buildyenclasses -outdir -outfile HelloJjfxug-01 gtjava ndashjar HelloJjfxug-01jar

Specify a class extends Application and has a main method

Specify a base directory to include a jar file Not java source files

Specify the name of jar file without extension name(jar)

javafxpackager command reference

httpdocsoraclecomjavafx2deploymentjavafxpackager001htm

Reference

bull Oracle Blogs [JavaFX] Native packaging for JavaFX bull httpsblogsoraclecomtalkingjavadeploymente

ntrynative_packaging_for_javafx

bull Oracle JavaFX Documents rdquoDeploying JavaFX Applicationsrdquo bull httpdocsoraclecomjavafx2deploymentjfxp

ub-deploymenthtm 55 Create the Main Application JAR File

Conclusion

bull JavaFX is not only GUI toolkit but also an application deployment toolkit

bull NetBeans IDE provides JavaFX deployment

bull JDK provides javafxpackager command Ant task

bull There is the e(fx)clipse plugin for eclipse user

(additional1) create MSI

bull javapackager can create a Windows MSI Installer

ndash Needs WiX(Windows Installer XML) Free

bull NetBeans 73 can create by native build

bull I introduced creating msi installer on my blog (Japanese only)

ndash httpdhatenanejptorutk20121119

(additinal2) Creating RPM

bull javapackager can create Linux RPM installer

ndash Needs rpmbuild command

bull NetBeans 73 can create by native build

bull May be create deb installer

(additional3) Note for sample program

To read a CSS file which is in the same directory with source file

Scene scene = new Scene(root 300 250) scenegetStylesheets()add( thisgetClass()getResource(HelloJjfxugcss)toExternalForm())

Sample CSS for specifying a font for Button class

button -fx-font-size 24 -fx-font-family Consolas sans-serif

JavaFX application with NetBeans (55)

bull add -Djavafxverbose=true option and execute the jar file generated by NetBeans

gtjava -Djavafxverbose=true -jar distyenHelloJjfxugjar 1) Try existing classpath ===== URL list fileCworkHelloJjfxugdistHelloJjfxugjar ===== 2) Try javafxruntimepath property

3) Look for cobundled JavaFX [javahome=CyenProgram FilesyenJavayenjdk170yenjre ===== URL list fileCworkHelloJjfxugdistHelloJjfxugjar fileCProgram20FilesJavajdk170jrelibjfxrtjar fileCProgram20FilesJavajdk170jrelibdeployjar fileCProgram20FilesJavajdk170jrelibpluginjar fileCProgram20FilesJavajdk170jrelibjavawsjar ===== Try calling ClassforName(hellojjfxugHelloJjfxug) using classLoader = javanet

URLClassLoader6f404c51 found class class hellojjfxugHelloJjfxug

Creating an executable JAR with command

bull Use javafxpackager command to create executable jar for JavaFX application

gtjavafxpackager -createjar -nocss2bin -appclass hellojjfxugHelloJjfxug -srcdir buildyenclasses -outdir -outfile HelloJjfxug-01 gtjava ndashjar HelloJjfxug-01jar

Specify a class extends Application and has a main method

Specify a base directory to include a jar file Not java source files

Specify the name of jar file without extension name(jar)

javafxpackager command reference

httpdocsoraclecomjavafx2deploymentjavafxpackager001htm

Reference

bull Oracle Blogs [JavaFX] Native packaging for JavaFX bull httpsblogsoraclecomtalkingjavadeploymente

ntrynative_packaging_for_javafx

bull Oracle JavaFX Documents rdquoDeploying JavaFX Applicationsrdquo bull httpdocsoraclecomjavafx2deploymentjfxp

ub-deploymenthtm 55 Create the Main Application JAR File

Conclusion

bull JavaFX is not only GUI toolkit but also an application deployment toolkit

bull NetBeans IDE provides JavaFX deployment

bull JDK provides javafxpackager command Ant task

bull There is the e(fx)clipse plugin for eclipse user

(additional1) create MSI

bull javapackager can create a Windows MSI Installer

ndash Needs WiX(Windows Installer XML) Free

bull NetBeans 73 can create by native build

bull I introduced creating msi installer on my blog (Japanese only)

ndash httpdhatenanejptorutk20121119

(additinal2) Creating RPM

bull javapackager can create Linux RPM installer

ndash Needs rpmbuild command

bull NetBeans 73 can create by native build

bull May be create deb installer

(additional3) Note for sample program

To read a CSS file which is in the same directory with source file

Scene scene = new Scene(root 300 250) scenegetStylesheets()add( thisgetClass()getResource(HelloJjfxugcss)toExternalForm())

Sample CSS for specifying a font for Button class

button -fx-font-size 24 -fx-font-family Consolas sans-serif

Creating an executable JAR with command

bull Use javafxpackager command to create executable jar for JavaFX application

gtjavafxpackager -createjar -nocss2bin -appclass hellojjfxugHelloJjfxug -srcdir buildyenclasses -outdir -outfile HelloJjfxug-01 gtjava ndashjar HelloJjfxug-01jar

Specify a class extends Application and has a main method

Specify a base directory to include a jar file Not java source files

Specify the name of jar file without extension name(jar)

javafxpackager command reference

httpdocsoraclecomjavafx2deploymentjavafxpackager001htm

Reference

bull Oracle Blogs [JavaFX] Native packaging for JavaFX bull httpsblogsoraclecomtalkingjavadeploymente

ntrynative_packaging_for_javafx

bull Oracle JavaFX Documents rdquoDeploying JavaFX Applicationsrdquo bull httpdocsoraclecomjavafx2deploymentjfxp

ub-deploymenthtm 55 Create the Main Application JAR File

Conclusion

bull JavaFX is not only GUI toolkit but also an application deployment toolkit

bull NetBeans IDE provides JavaFX deployment

bull JDK provides javafxpackager command Ant task

bull There is the e(fx)clipse plugin for eclipse user

(additional1) create MSI

bull javapackager can create a Windows MSI Installer

ndash Needs WiX(Windows Installer XML) Free

bull NetBeans 73 can create by native build

bull I introduced creating msi installer on my blog (Japanese only)

ndash httpdhatenanejptorutk20121119

(additinal2) Creating RPM

bull javapackager can create Linux RPM installer

ndash Needs rpmbuild command

bull NetBeans 73 can create by native build

bull May be create deb installer

(additional3) Note for sample program

To read a CSS file which is in the same directory with source file

Scene scene = new Scene(root 300 250) scenegetStylesheets()add( thisgetClass()getResource(HelloJjfxugcss)toExternalForm())

Sample CSS for specifying a font for Button class

button -fx-font-size 24 -fx-font-family Consolas sans-serif

Reference

bull Oracle Blogs [JavaFX] Native packaging for JavaFX bull httpsblogsoraclecomtalkingjavadeploymente

ntrynative_packaging_for_javafx

bull Oracle JavaFX Documents rdquoDeploying JavaFX Applicationsrdquo bull httpdocsoraclecomjavafx2deploymentjfxp

ub-deploymenthtm 55 Create the Main Application JAR File

Conclusion

bull JavaFX is not only GUI toolkit but also an application deployment toolkit

bull NetBeans IDE provides JavaFX deployment

bull JDK provides javafxpackager command Ant task

bull There is the e(fx)clipse plugin for eclipse user

(additional1) create MSI

bull javapackager can create a Windows MSI Installer

ndash Needs WiX(Windows Installer XML) Free

bull NetBeans 73 can create by native build

bull I introduced creating msi installer on my blog (Japanese only)

ndash httpdhatenanejptorutk20121119

(additinal2) Creating RPM

bull javapackager can create Linux RPM installer

ndash Needs rpmbuild command

bull NetBeans 73 can create by native build

bull May be create deb installer

(additional3) Note for sample program

To read a CSS file which is in the same directory with source file

Scene scene = new Scene(root 300 250) scenegetStylesheets()add( thisgetClass()getResource(HelloJjfxugcss)toExternalForm())

Sample CSS for specifying a font for Button class

button -fx-font-size 24 -fx-font-family Consolas sans-serif

Conclusion

bull JavaFX is not only GUI toolkit but also an application deployment toolkit

bull NetBeans IDE provides JavaFX deployment

bull JDK provides javafxpackager command Ant task

bull There is the e(fx)clipse plugin for eclipse user

(additional1) create MSI

bull javapackager can create a Windows MSI Installer

ndash Needs WiX(Windows Installer XML) Free

bull NetBeans 73 can create by native build

bull I introduced creating msi installer on my blog (Japanese only)

ndash httpdhatenanejptorutk20121119

(additinal2) Creating RPM

bull javapackager can create Linux RPM installer

ndash Needs rpmbuild command

bull NetBeans 73 can create by native build

bull May be create deb installer

(additional3) Note for sample program

To read a CSS file which is in the same directory with source file

Scene scene = new Scene(root 300 250) scenegetStylesheets()add( thisgetClass()getResource(HelloJjfxugcss)toExternalForm())

Sample CSS for specifying a font for Button class

button -fx-font-size 24 -fx-font-family Consolas sans-serif

(additional1) create MSI

bull javapackager can create a Windows MSI Installer

ndash Needs WiX(Windows Installer XML) Free

bull NetBeans 73 can create by native build

bull I introduced creating msi installer on my blog (Japanese only)

ndash httpdhatenanejptorutk20121119

(additinal2) Creating RPM

bull javapackager can create Linux RPM installer

ndash Needs rpmbuild command

bull NetBeans 73 can create by native build

bull May be create deb installer

(additional3) Note for sample program

To read a CSS file which is in the same directory with source file

Scene scene = new Scene(root 300 250) scenegetStylesheets()add( thisgetClass()getResource(HelloJjfxugcss)toExternalForm())

Sample CSS for specifying a font for Button class

button -fx-font-size 24 -fx-font-family Consolas sans-serif

(additinal2) Creating RPM

bull javapackager can create Linux RPM installer

ndash Needs rpmbuild command

bull NetBeans 73 can create by native build

bull May be create deb installer

(additional3) Note for sample program

To read a CSS file which is in the same directory with source file

Scene scene = new Scene(root 300 250) scenegetStylesheets()add( thisgetClass()getResource(HelloJjfxugcss)toExternalForm())

Sample CSS for specifying a font for Button class

button -fx-font-size 24 -fx-font-family Consolas sans-serif

(additional3) Note for sample program

To read a CSS file which is in the same directory with source file

Scene scene = new Scene(root 300 250) scenegetStylesheets()add( thisgetClass()getResource(HelloJjfxugcss)toExternalForm())

Sample CSS for specifying a font for Button class

button -fx-font-size 24 -fx-font-family Consolas sans-serif