2016-02-12 39 views
0

我在嘗試部署JavaFX應用程序時遇到了一些麻煩。爲了簡化我的問題,我試圖對「Hello word」應用程序做同樣的事情,問題是一樣的。無法執行未捆綁JRE的JavaFX應用程序

我目前使用IntelliJ IDEA和Gradle。

build.gradle文件是這樣的:

apply plugin: 'java' 
apply from: "http://dl.bintray.com/content/shemnon/javafx-gradle/8.1.1/javafx.plugin" 

repositories { 
    mavenCentral() 
} 

javafx { 
    mainClass 'Main' 
} 

build.gradle文件的工作。問題是它將JRE嵌入到捆綁包中,因此文件大小大約爲175 MB。對於簡單的「Hello World」應用來說,這太過分了,你不覺得嗎?所以,我想捆綁這個簡單的應用程序沒有JRE(是的,我知道我應該分發我的應用程序與JRE捆綁,所以它不會中繼使用系統,但我要分發這兩個版本:有和沒有捆綁JRE)。爲了做到這一點,我添加一行到build.gradle文件(如this link解釋:

Java runtime to be bundled: none, bundle will rely on locally installed runtimes 
... 
Skipping Mac Application Image because of configuration error The file for the Runtime/JRE directory does not exist. 
Advice to Fix: Point the runtime parameter to a directory that containes the JRE. 
Skipping DMG Installer because of configuration error The file for the Runtime/JRE directory does not exist. 
Advice to Fix: Point the runtime parameter to a directory that containes the JRE. 
Skipping PKG Installer because of configuration error The file for the Runtime/JRE directory does not exist. 
Advice to Fix: Point the runtime parameter to a directory that containes the JRE. 
Skipping Mac App Store Ready Bundler because of configuration error The file for the Runtime/JRE directory does not exist. 
Advice to Fix: Point the runtime parameter to a directory that containes the JRE. 

... 
javafx { 
    mainClass 'Main' 
    javaRuntime '<NO RUNTIME>' 
} 

但當gradle jfxDeploy事實上,運行gradle jfxDeploy -i表現出一些有趣的信息沒有束產生

好了,所以也許插件有一些錯誤我嘗試用javapackager生成包,我去項目文件夾並運行以下命令:。

javapackager -deploy -native image -srcfiles build/libs/ -outdir build/distributions -outfile Sample -appclass Main 

輸出正常。嵌入的JRE可以正確生成包。現在,我嘗試生成一個包沒有與此JRE:

javapackager -deploy -native image -srcfiles build/libs/ -outdir build/distributions -outfile Sample -appclass Main -Bruntime= 

(這是相同的命令附加-Bruntime=this link解釋)。

該包已生成。現在它的大小約爲500 KB。但是當我嘗試運行它時,沒有任何反應。在終端中運行它會產生以下(簡化)輸出:

$ Main.app/Contents/MacOS/Main 
Failed to find library.: 
Main:Failed to locate JNI_CreateJavaVM 
Main:Failed to launch JVM 

似乎該捆綁軟件無法啓動本地JVM。 jar被正確生成並添加到包中。運行它java -jar運行應用程序,但我不知道爲什麼它運行時不起作用

僅供參考,我在OS X 10.11中運行java 1.8.0_74,javac 1.8.0_74和javapackager 8.0 .2

+0

你試過升級到JDK的當前版本? – FibreFoX

+0

我剛剛升級了我的JDK版本。問題仍然存在 – Pelocho

回答

0

shemnon的javafx.plugin沒有開發,也沒有維護,因此我創建了javafx-gradle-plugin

問題伴隨着.cfg-文件格式的內部更改,它們現在使用INI文件,但在RUNTIME配置方面存在缺陷。

官方JDK-bug的門票由我報道:
(JDK 9)https://bugs.openjdk.java.net/browse/JDK-8143314

(JDK 8)https://bugs.openjdk.java.net/browse/JDK-8143934

它應該足夠你的構建中的一些捆綁參數的launcher-cfg-format設置爲cfg (或使用javafx-gradle-plugin,它自動包含該解決方法)。

聲明:我是javafx-maven-plugin的維護者,也是javafx-gradle-plugin的創建者和維護者。

UPDATE這引起了固定,並提供與JDK 8u92

+0

來自javafx-maven-plugin的相關問題票據是這樣的:https://github.com/javafx-maven-plugin/javafx-maven-plugin/issues/167 – FibreFoX

+0

謝謝,夥計。有效。在完整的文檔發佈之前,我假設所有的配置參數都出現在[JavaFXGradlePluginExtension.java](https://github.com/FibreFoX/javafx-gradle-plugin/blob/master/src/main/java/de/ dynamicfiles/projects/gradle/plugins/javafx/JavaFXGradlePluginExtension.java) – Pelocho

+0

@ Dr.Pelocho是的,你是對的!由於這是我的業餘時間項目,我大大落後於我的日程安排;)但文件將盡快提供。 – FibreFoX