2013-01-16 75 views
3

我們創建了一個JavaFX應用程序,其中包含許多TableView以顯示數據。 我們已經建立了使用螞蟻本地捆綁,並且我們混淆罐子Proguard的-4.8,我們能夠創建使用混淆的JAR成功本地捆綁EXE。當我們運行exe時,它成功啓動應用程序,所有的東西都正常工作,數據存在於tableView中,但我們無法在TableView中看到數據。下面是從exe中獲取的用於TableView的屏幕截圖:JavaFX bundle exe未顯示TableView內容

注意:我們能夠在不使用混淆的情況下使用jar和exe創建TableView中的數據。

TableView

步驟混淆罐子中的build.xml

<target name="ObfuscatingProject" depends="apidocs"> 

      <taskdef resource="proguard/ant/task.properties" classpath="${WorkingFolder}/proguard.jar" /> 
      <proguard> 
       -dontusemixedcaseclassnames 
       -printmapping Project_Proguard.map 
       -dontshrink 
       -dontoptimize 
       -dontskipnonpubliclibraryclasses 
       -dontskipnonpubliclibraryclassmembers 

       -libraryjars "${java.home}/lib/rt.jar" 
       -libraryjars "${java.home}/lib/javaws.jar" 
       -libraryjars "${env.JAVA_HOME}/lib/ant-javafx.jar" 
       -libraryjars "${env.JAVA_HOME}/jre/lib/jfxrt.jar"   
       -libraryjars ${WorkingFolder}/libs/BareBonesBrowserLaunch.jar 
       -libraryjars ${WorkingFolder}/libs/activation.jar 
       -libraryjars ${WorkingFolder}/libs/log4j-1.2.16.jar 
       -libraryjars ${WorkingFolder}/libs/commons-codec-1.5.jar 
       -libraryjars ${WorkingFolder}/libs/commons-httpclient-3.1.jar 
       -libraryjars ${WorkingFolder}/libs/commons-logging-1.1.1.jar 
       -libraryjars ${WorkingFolder}/libs/commons-io-2.0.1.jar 
       -libraryjars ${WorkingFolder}/libs/xercesImpl-2.9.1.jar 
       -libraryjars ${WorkingFolder}/libs/javax.mail.jar 
       -libraryjars ${WorkingFolder}/libs/balloontip-1.2.1.jar 
       -libraryjars ${WorkingFolder}/libs/httpclient-4.1.1.jar 
       -libraryjars ${WorkingFolder}/libs/httpcore-4.1.3.jar 
       -libraryjars ${WorkingFolder}/libs/jcifs-1.3.16.jar   
       -libraryjars ${WorkingFolder}/libs/proguard-4.8.jar 
       -libraryjars ${WorkingFolder}/libs/xml-apis-1.3.04.jar 
       -libraryjars ${WorkingFolder}/libs/swingx-1.6.jar 
       -libraryjars ${WorkingFolder}/libs/derby.jar 


       -injars ${WorkingFolder}/${app.name}.jar 
       -injars ${WorkingFolder}/CustomJars/LicVerifier.jar(!META-INF/MANIFEST.MF) 
       -injars ${WorkingFolder}/CustomJars/LicUtility.jar(!META-INF/MANIFEST.MF) 


       -outjars ${WorkingFolder}/ObfuscatedProjectJar/ProjectObfuscated.jar 

       -ignorewarnings 

       -keepattributes 

       Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,LocalVariable*Table,*Annotation*,Synthetic,EnclosingMethod 
       -adaptresourcefilecontents **.fxml,**.properties,META-INF/MANIFEST.MF,images/*.jar,Project.version 

       -keepclassmembernames class * { 
        @javafx.fxml.FXML *; 
       } 

       -keepclassmembernames class com.javafx.main.Main { 
        public static void main(java.lang.String[]); 
       } 


       -keep class com.javafx.main.* 

       -keepclasseswithmembers public class com.javafx.main.Main{ 
        public static void main(java.lang.String[]); 
       } 

       -keepclasseswithmembers public class com.project.main.ProjectEntryFX{ 
        public static void main(java.lang.String[]); 
       } 

       -keepclasseswithmembers public class net.project.license.LicEntryPoint{ 
        public *; 
       } 


       -keep class * extends org.xml.sax.helpers.DefaultHandler 

       -keepclassmembers class * extends org.xml.sax.helpers.DefaultHandler { 
        private *; 
         public *; 
       } 

      </proguard> 
    </target> 

有人建議我去改進哪些看到JavaFX的TableView中的數據?

感謝您的幫助!

回答

3

javaFx必須訪問你的類的一些方法考慮他們的名字。

例如:如果你有一個Person類蒙山attribue姓名,......你大概寫道:

public Class Person { 

private StringProperty name, surname,.... 

public StringProperty nameProperty() { 
     return name; 
    } 

public StringProperty surnameProperty() { 
     return surname; 
} 

... 

} 

方法,如nameProperty,surnNameProperty可很可能在你的應用程序通過代碼訪問是這樣的:

new PropertyValueFactory<Person, String>("name") 
new PropertyValueFactory<Person, String>("surName") 

混淆器不得重命名這些方法(nameProperty,surnameProperty ...)。你可以用這樣的配置告訴它:

-keepclassmembers public class yourpackage.** { 
    public javafx.beans.property.StringProperty *Property(); 
} 
+0

天才!最後我修復了它。 – Krzysiek

+0

如果我的班是Blackout,而且是在包模型中,我應該寫model.Blackout?我應該在哪裏添加該配置? – lmiguelvargasf