Default JVM flags

Discussion in 'Java' started by CD1, Jun 22, 2008.

  1. CD1

    CD1 Guest

    Hi!

    I always run a Java class which takes a lot of memory, and every time
    I have to set the maximum memory to some value. For example:

    java -Xmx512m MyClass

    How do I set this flag to be the default to all the future invocations
    of the JVM? I didn't want to type that every time. I know I can set
    the default Swing flags in the file $JDK_HOME/jre/lib/
    swing.properties. Is there an equivalent of that file to the JVM (not
    Swing related)?

    Thanks!
     
    CD1, Jun 22, 2008
    #1
    1. Advertising

  2. CD1

    Daniel Pitts Guest

    CD1 wrote:
    > Hi!
    >
    > I always run a Java class which takes a lot of memory, and every time
    > I have to set the maximum memory to some value. For example:
    >
    > java -Xmx512m MyClass
    >
    > How do I set this flag to be the default to all the future invocations
    > of the JVM? I didn't want to type that every time. I know I can set
    > the default Swing flags in the file $JDK_HOME/jre/lib/
    > swing.properties. Is there an equivalent of that file to the JVM (not
    > Swing related)?
    >
    > Thanks!

    You can create a script file that starts "java" with the appropriate
    arguments.

    --
    Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
     
    Daniel Pitts, Jun 22, 2008
    #2
    1. Advertising

  3. CD1

    Roedy Green Guest

    On Sun, 22 Jun 2008 11:10:47 -0700 (PDT), CD1
    <> wrote, quoted or indirectly quoted someone
    who said :

    >I always run a Java class which takes a lot of memory, and every time
    >I have to set the maximum memory to some value. For example:
    >
    >java -Xmx512m MyClass


    one way is to write a kicker, a tiny C program that uses a C-exec to
    launch with the default switches you want.

    See http://mindprod.com/project/kicker.html
    --

    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
     
    Roedy Green, Jun 22, 2008
    #3
  4. CD1

    CD1 Guest

    Yeah, that's what I'm going to do if nothing else works. I thought
    there was an official way of doing that, using a properties file. But
    thanks anyway, I'll do it as you said!
     
    CD1, Jun 22, 2008
    #4
  5. CD1

    Arne Vajhøj Guest

    Roedy Green wrote:
    > On Sun, 22 Jun 2008 11:10:47 -0700 (PDT), CD1
    > <> wrote, quoted or indirectly quoted someone
    > who said :
    >> I always run a Java class which takes a lot of memory, and every time
    >> I have to set the maximum memory to some value. For example:
    >>
    >> java -Xmx512m MyClass

    >
    > one way is to write a kicker, a tiny C program that uses a C-exec to
    > launch with the default switches you want.


    If one want to spend the time to create a program to start
    with then it is minimal extra work to actually start the JVM
    instead of spawn/exec java.exe !

    Arne
     
    Arne Vajhøj, Jun 22, 2008
    #5
  6. CD1

    Roedy Green Guest

    On Sun, 22 Jun 2008 15:58:26 -0400, Arne Vajhøj <>
    wrote, quoted or indirectly quoted someone who said :

    >If one want to spend the time to create a program to start
    >with then it is minimal extra work to actually start the JVM
    >instead of spawn/exec java.exe !


    You can do it with a bat file, which is a generic sort of kicker, and
    somewhat larger than the C kicker would be. The C kicker does nothing
    but the EXEC. A shell has the full ability to interpret scripts.

    The C kicker has the advantage you can put it in the aux path in the
    registry, which you can't do with bat files. See
    http://mindprod.com/jgloss/registry.html

    If you write a kicker, you can stomp them out like cookies, with theme
    and variations for various purposes. My kicker project, originated in
    the DOS days, was to make it possible to create them without a C
    compiler or programming knowledge.
    --

    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
     
    Roedy Green, Jun 22, 2008
    #6
  7. Wayne wrote:
    > Roedy Green wrote:
    >> On Sun, 22 Jun 2008 15:58:26 -0400, Arne Vajhøj <>
    >> wrote, quoted or indirectly quoted someone who said :
    >>> If one want to spend the time to create a program to start
    >>> with then it is minimal extra work to actually start the JVM
    >>> instead of spawn/exec java.exe !

    >>
    >> You can do it with a bat file, which is a generic sort of kicker, and
    >> somewhat larger than the C kicker would be. The C kicker does nothing
    >> but the EXEC. A shell has the full ability to interpret scripts.
    >>
    >> The C kicker has the advantage you can put it in the aux path in the
    >> registry, which you can't do with bat files. See
    >> http://mindprod.com/jgloss/registry.html
    >>
    >> If you write a kicker, you can stomp them out like cookies, with theme
    >> and variations for various purposes. My kicker project, originated in
    >> the DOS days, was to make it possible to create them without a C
    >> compiler or programming knowledge.

    >
    > Didn't there used to be (or is there still) a "jvm.cfg" text file one
    > could edit for this?


    It is still there in 1.6, but can you set Xmx in that ?

    Arne
     
    Arne Vajhøj, Jun 22, 2008
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Hooke

    Re: Handling both MS JVM and Sun JVM

    Kevin Hooke, Aug 26, 2003, in forum: Java
    Replies:
    2
    Views:
    877
  2. Lasse
    Replies:
    1
    Views:
    700
    Jon A. Cruz
    Jan 5, 2004
  3. Young-Jin Lee

    MS JVM and Sun JVM problem

    Young-Jin Lee, Jan 20, 2004, in forum: Java
    Replies:
    3
    Views:
    575
    Mickey Segal
    Jan 21, 2004
  4. Steve Holden
    Replies:
    0
    Views:
    781
    Steve Holden
    Feb 8, 2009
  5. Alex Hunsley
    Replies:
    1
    Views:
    281
    Alex Hunsley
    Apr 7, 2005
Loading...

Share This Page