How to set default parameters to jvm?
Asked Answered
B

2

8

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.

Bestiality answered 1/2, 2013 at 8:12 Comment(0)
R
11

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
....
Refugio answered 1/2, 2013 at 8:34 Comment(2)
thanks for your advice. And another problem is that when I run this code: System.out.println(TimeZone.getDefault()); output is sun.util.calendar.ZoneInfo[id="America/Caracas",offset=-16200000,dstSavings=0,useDaylight=false,transitions=5,lastRule=null] How to change this another way?Bestiality
Use one of the TimeZone methods eg TimeZone.getDefault().getDisplayName()Refugio
P
4

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

Parrisch answered 1/2, 2013 at 8:22 Comment(5)
This is not what the OP asked for.Neolamarckism
@bmargulies, what is the difference? Post your answer.Parrisch
Rereading his tortured syntax I'm no longer sure that there's a problem with your answer.Neolamarckism
@bmargulies, yes, his question is not clear. The current two answers are supplemental to each other with current question formulation.Parrisch
so what if I have no eclipse and no command line - is there a default configuration file? maybe some kind of default property file but where?Campion

© 2022 - 2024 — McMap. All rights reserved.