How to create an executable jar file with 1 GB heap

后端 未结 3 1100
我寻月下人不归
我寻月下人不归 2021-01-23 08:14

I created a class that gives a text file containing system performance as output. I want to run it as an executable Jar. but when I run the Jar I want to increa

相关标签:
3条回答
  • 2021-01-23 08:46
    <launch4jConfig>
      <dontWrapJar>false</dontWrapJar>
      <headerType>gui</headerType>
      <jar>PATH_OF_YOUR_JAR</jar>
      <outfile>PATH_OF_YOUR_EXE</outfile>
      <errTitle></errTitle>
      <cmdLine>-log_file=logs\\hp</cmdLine>
      <chdir></chdir>
      <priority>normal</priority>
      <downloadUrl>http://java.com/download</downloadUrl>
      <supportUrl></supportUrl>
      <customProcName>true</customProcName>
      <stayAlive>false</stayAlive>
      <manifest></manifest>
      <icon>PATH_OF_THE_ICON</icon>
      <singleInstance>
        <mutexName>APPLICATION_NAME</mutexName>
        <windowTitle></windowTitle>
      </singleInstance>
      <jre>
        <path>jre-w32\</path>
        <minVersion></minVersion>
        <maxVersion></maxVersion>
        <jdkPreference>preferJre</jdkPreference>
        <initialHeapSize>512</initialHeapSize>  
        <maxHeapSize>1024</maxHeapSize>
      </jre>
    </launch4jConfig>
    

    It is a launch4j Config file, here you can specify the heap size as per your requirement.

    0 讨论(0)
  • 2021-01-23 08:50
     java -Xms1200m -Xmx1300m -jar FILENAME.jar
    

    Define this somewhere in the jar File or in the Manifest is not possible:

    Can I set Java max heap size for running from a jar file?

    0 讨论(0)
  • 2021-01-23 08:53

    As already mentioned: it unfortunately is not possible (without creating a wrapper, whether shortcut/script/executable ...).

    If you're only running on Windows, I can recommend Launch4J to create an executable wrapper that can apply these settings on execution:

    Wrapping it in a executable has other benefits:

    • If a suitable version of Java is not found, it will prompt the user to download it
    • Windows 7 Start Menu will treat it properly (highlighting it as a new application after installation)
    • Windows Firewall will treat it properly
    0 讨论(0)
提交回复
热议问题