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和調用程序來執行的。