1

I want to modify the default jvm setting, like gc policy and Xmx. Because of some reason, I can't modify the starting command of java program to add these setting. Is there any ways to do that?

Thanks.

[updated]

Sorry I didn't describe it clearly.

It is something like server side job program which is started from another server program. Because of the default Xmx is too big(on 64 bit server), minor GC time is too long, almost 1 second. So I want to change the default GC policy to test. And for now, the server program can't be modified.

Mavlarn
  • 3,807
  • 2
  • 37
  • 57

2 Answers2

1

You can have the Java program relaunch itself. You can have a bootstrap main which is called first. It then does a Runtime.exec(...) with the command line option you require running a different Class.main() which is the actual program.

CAMOBAP
  • 5,523
  • 8
  • 58
  • 93
Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
0

Short answer: with your requirements you can't do this.

Theoretically you have 2 possibilities:

  1. Provide settings via comand line options:

    I can't modify the starting command of java program to add these setting

  2. Change settings at run time:

    But it's impossible

Community
  • 1
  • 1
CAMOBAP
  • 5,523
  • 8
  • 58
  • 93
  • 2
    There's a 3. hackish way, rename the java executable, replace it with a .bat/shell script that invokes the original java executable with the altered command line options. – nos Nov 14 '12 at 11:58