I'd like to know how I can pass parameters to JVM before it is started. For example,
I think I need to modify JVM timezone parameter.
I use eclipse with windows 7.
-- Go to the Eclipse Window > preferences, in "Java > Installed JREs". -- Copy the current default JRE with a new name, for example myJRE. -- Select the new JRE and click on the "Edit" button. -- In the "Edit JRE" dialog, add your JVM arguments in the "Default VM Arguments" field.
Configuring JVM OptionsAccess the Server Manager, and choose the Java tab. Click JVM Options and make the necessary changes. Click OK.
To add JVM parameters, choose New . The property is added to Custom parameters . The actual parameters used by a running JVM can be found in the development trace file of the corresponding server process. This results in parameter: "-agentlib:myagent=port=12345,dir=C:/Mydir" .
In Eclipse go to
Run As -> Run Configurations -> Arguments -> VM Arguments
and set required JMV argument, eg
-Duser.timezone=PST
you can get all timezone IDs available in JVM by running this test
for(String id : TimeZone.getAvailableIDs()) {
System.out.println(id);
}
output
Etc/GMT+12
Etc/GMT+11
Pacific/Midway
Pacific/Niue
Pacific/Pago_Pago
Pacific/Samoa
....
JVM parameters are specified in command line with -D
java -Dfile.encoding=utf-8 -jar myApp.jar
In your case use -Duser.timezone
How to set a JVM TimeZone Properly
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With