2012-12-25 17 views
0

我們開發一個使用musicg庫的應用程序,當我們在eclipse中運行程序時,出現了outofmemory異常。 下面是這個類如何在eclipse中使用launch4j來運行應用程序並開發

public class FingerprintDemo{ 

    public static void main (String[] args){ 

     String filename = "Fun - Some Nights (ORIGINAL.wav"; 

     // create a wave object 
     Wave wave = new Wave("D:\\DropBox\\Dropbox\\Convencion 2012\\AUDIOS WAV/"+filename); 

     // get the fingerprint 
     byte[] fingerprint=wave.getFingerprint(); 

     // dump the fingerprint 
     FingerprintManager fingerprintManager=new FingerprintManager(); 
     fingerprintManager.saveFingerprintAsFile(fingerprint, "out/"+filename+".fingerprint"); 

     // load fingerprint from file 
     byte[] loadedFp=fingerprintManager.getFingerprintFromFile("out/"+filename+".fingerprint"); 

     /* 
     // fingerprint bytes checking 
     for (int i=0; i<fingerprint.length; i++){ 
      System.out.println(fingerprint[i]+" vs "+loadedFp[i]); 
     } 
     */ 
    } 
} 

當我運行這個程序時,它給下面的例外。

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space 
    at com.musicg.wave.extension.Spectrogram.buildSpectrogram(Spectrogram.java:117) 
    at com.musicg.wave.extension.Spectrogram.<init>(Spectrogram.java:76) 
    at com.musicg.wave.Wave.getSpectrogram(Wave.java:237) 
    at com.musicg.fingerprint.FingerprintManager.extractFingerprint(FingerprintManager.java:83) 
    at com.musicg.wave.Wave.getFingerprint(Wave.java:329) 
    at com.musicg.main.demo.FingerprintDemo.main(FingerprintDemo.java:31) 

我做的類的罐子和Launch4j配置並執行,它的做工精細用了異常。

<launch4jConfig> 
    <dontWrapJar>false</dontWrapJar> 
    <headerType>gui</headerType> 
    <jar>D:\musicg\musicg.jar</jar> 
    <outfile>D\musicg\\\musicg\.exe</outfile> 
    <errTitle>MusicG</errTitle> 
    <cmdLine></cmdLine> 
    <chdir></chdir> 
    <priority>normal</priority> 
    <downloadUrl>http://java.com/download</downloadUrl> 
    <supportUrl></supportUrl> 
    <customProcName>true</customProcName> 
    <stayAlive>false</stayAlive> 
    <manifest></manifest> 
    <icon></icon> 
    <jre> 
    <path>C:\Program Files\Java\jre7\</path> 
    <minVersion>1.4.0</minVersion> 
    <maxVersion></maxVersion> 
    <jdkPreference>preferJre</jdkPreference> 
    <initialHeapSize>512</initialHeapSize> 
    <maxHeapSize>512</maxHeapSize> 
    </jre> 
</launch4jConfig> 

請誰能幫助如何擺脫這種異常或如何配置launch4j在Eclipse和調用程序來執行的。

回答

0

您在Eclipse中收到OutOfMemoryError,因爲您沒有增加運行配置中的最大堆大小。然而,在您的Launch4J腳本中,您確實增加了它:<maxHeapSize>512</maxHeapSize>

要修復Eclipse中的問題,請打開Run Configurations dialog。切換到Arguments選項卡並輸入您的Xmx(最大堆大小)參數。

enter image description here

這真的不適合從Eclipse中運行你的Launch4J腳本,使用運行配置爲。雖然你可以創建一個Ant腳本來運行Launch4J並構建你的.exe。

相關問題