aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes How to set Environment variable to set -Duser.timezone property for JVM? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "How to set Environment variable to set -Duser.timezone property for JVM?" Watch "How to set Environment variable to set -Duser.timezone property for JVM?" New topic
Author

How to set Environment variable to set -Duser.timezone property for JVM?

kunu patil
Greenhorn

Joined: Sep 24, 2007
Posts: 20
Hi

I want to set -Duser.timezone property in Windows NT with a particular timezone. In Eclipse I could set it using Runtime confguration. The same I could do using argument to Java command. However, I want to do the same by using Environment Vto set -Duser.timezone property for JVM. Is it possible to do so? If yes, then how can I do that?

Appreciate your help.

Thanks in advance
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19692
    
  20

Since with "Environment" you mean something that's part of your IDE (I'm guessing Eclipse) I'm moving this thread to our IDEs forum.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
kunu patil
Greenhorn

Joined: Sep 24, 2007
Posts: 20
Hi Rob

By Environment I meant Environmental Variables..
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18563
    
    8

And by "environmental variables" you meant... what?
kunu patil
Greenhorn

Joined: Sep 24, 2007
Posts: 20
I mean System Variables, which we set in Windows by - "Right Click on My Computer > System Properties> Advanced" ...For example, we set Classpath there...
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18563
    
    8

Oh, okay. Then you pick a name -- let's call it JAVA_TIME_ZONE -- and create an environment variable whose value is "-Duser.timezone=whatever". Then at the command line, instead of doing

you do this instead:

Although I don't know why you would want to do that; it doesn't really help with any problem that I can see.
kunu patil
Greenhorn

Joined: Sep 24, 2007
Posts: 20
Hi Paul

Thanks for the reply.

Is there any way to use this environment variable without passing it as an argument to java command?
That is, If I set this environment variable as you suggested and then just run java program using-
, how will this program pick up value of the said environment variable?

I want to acheive this: Whenever any Java program runs on my machine it should use the timezone specified through the environment variable.

Thanks.
Akhil Kashyap
Greenhorn

Joined: Feb 12, 2010
Posts: 17
Hi Kunu,

Can you please tell me how to set time zone for Eclipse.

I am using JDK 5 and Eclipse Galileo. Eclipse shows time as per GMT in console where as I am in IST. Windows is displaying time perfectly fine.


Thanks in advance.


Akhil Kashyap
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to set Environment variable to set -Duser.timezone property for JVM?