[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Increasing Heap size in Java

Posted on 2006-05-16
7
Medium Priority
?
4,741 Views
Last Modified: 2013-11-23
How can I increase the heap memory of a JVM Permanently.

I want to run an executable jar file, for which 64MB heap is not enough(Preferable 512).

Is it possible to do it in the program??
I am using Apache ANT for building the program. Is it possible to specify in build.xml??

Please help me in this regard

Thanks & regards
0
Comment
Question by:sree032397
7 Comments
 
LVL 14

Expert Comment

by:MilanKM
ID: 16688888
0
 
LVL 1

Author Comment

by:sree032397
ID: 16689036
But this is useful for temporary purpose only. I want it to be permanent
0
 
LVL 25

Accepted Solution

by:
InteractiveMind earned 2000 total points
ID: 16689086
> Is it possible to do it in the program??

No.

Available JVM memory must be specified on execution of the JVM; the JVM is executed prior to loading and running any application, so the only way to do this is really with parameters to java.exe/javaw.exe/..

A lot of Java applications are initialized either using an EXE, or a simple BAT script — as these can specify mem size to the JVM during initialization.


I agree that it's a pain.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Author Comment

by:sree032397
ID: 16689272
Thank you,
Is it possible to specify the heap size in Build.xml while using ANT
0
 
LVL 1

Expert Comment

by:d_g_watson
ID: 16690645
Yes, if you're using the ant task "java" to run your jar file, you can set the heap size within the task, like this:

        <java jar="test.jar"
           fork="true"
           failonerror="true"
           maxmemory="512m"
           >
         <arg value="-h"/>
         <classpath>
           <pathelement location="test.jar"/>
           <pathelement path="${java.class.path}"/>
         </classpath>
       </java>

Alternatively, you can set the JVM args like this:

  <java .....>
    <jvmarg value="–Xms512m –Xmx512m"/>
  </java>


Hope that helps,
Dave.
0
 
LVL 1

Author Comment

by:sree032397
ID: 16696476
Thank you,

That works fine,
Is it possible to specify it while running aw executable jar file(Double lick).
or is it possible to hide the command prompty while running a bat file??

0
 
LVL 1

Expert Comment

by:d_g_watson
ID: 16698673
> Is it possible to specify it while running aw executable jar file

Does the first ant example, above, not do this?

> is it possible to hide the command prompty while running a bat file

In your batch file, use the "javaw" command, rather than "java". "javaw" is the same as "java", except there's no associated console.

Dave.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
Loops Section Overview
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month18 days, 2 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question