[英]How to use launch4j in Eclipse to run the application and develop it?
当我们在Eclipse中运行程序而导致内存不足时,我们正在使用musicg库开发应用程序。
下面是课程
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)
我做了该类的jar,并在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>
如何摆脱这种异常,或者如何在Eclipse中配置launch4j并调用程序以执行?
您在Eclipse中遇到了OutOfMemoryError,因为您没有在运行配置中增加最大堆大小。 但是,在Launch4J脚本中,确实增加了它: <maxHeapSize>512</maxHeapSize>
要在Eclipse中解决该问题,请打开“ 运行配置”对话框 。 切换到“参数”选项卡,然后输入Xmx(最大堆大小)参数。
从Eclipse运行Launch4J脚本确实不合适,为此使用“运行配置”。 尽管您可以创建一个说说Ant脚本,该脚本将运行Launch4J并构建您的.exe。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.