简体   繁体   English

如何在Eclipse中使用launch4j来运行应用程序并进行开发?

[英]How to use launch4j in Eclipse to run the application and develop it?

We are developing an application using musicg library, when we run the program in eclipse getting outofmemory exception. 当我们在Eclipse中运行程序而导致内存不足时,我们正在使用musicg库开发应用程序。

Below is the class 下面是课程

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]);
        }
        */
    }
}

When I run this program it give below exception. 当我运行该程序时,它给出以下异常。

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)

I did the jar of the class and configured it in Launch4j and executed, it's working fine with out exception. 我做了该类的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>

How to get rid of this exception or how to configure launch4j in Eclipse and call the program to execute? 如何摆脱这种异常,或者如何在Eclipse中配置launch4j并调用程序以执行?

You are getting an OutOfMemoryError in Eclipse because you have not increased the maximum heap size in your Run Configuration. 您在Eclipse中遇到了OutOfMemoryError,因为您没有在运行配置中增加最大堆大小。 In your Launch4J script however, you did increase it: <maxHeapSize>512</maxHeapSize> 但是,在Launch4J脚本中,确实增加了它: <maxHeapSize>512</maxHeapSize>

To fix the issue in Eclipse, open the Run Configurations dialog . 要在Eclipse中解决该问题,请打开“ 运行配置”对话框 Switch to the Arguments tab and enter your Xmx (max heap size) argument. 切换到“参数”选项卡,然后输入Xmx(最大堆大小)参数。

在此处输入图片说明

It's really not appropriate to run your Launch4J script from Eclipse, use the Run Configurations for that. 从Eclipse运行Launch4J脚本确实不合适,为此使用“运行配置”。 Although you can create say an Ant script that will run Launch4J and build your .exe. 尽管您可以创建一个说说Ant脚本,该脚本将运行Launch4J并构建您的.exe。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM