Problem with System.getProperties(windir)

I am using String fileName = System.getenv("windir")
It is giving :

Exception in thread "main" java.lang.Error: getenv no longer supported, use prop
erties and -D instead: windir
        at java.lang.System.getenv(Unknown Source)
        at com.util.createLog2.calculate(createLog2.java:41)
        at com.Main.main(Main.java:390)
LVL 1
sree032397Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sree032397Author Commented:
Sorry System.getenv("windir")
Ajay-SinghCommented:
looks like you need to upgrade java: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4199068
Mayank SPrincipal TechnologistCommented:
System.getProperty ( "windir" ) ;
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Mayank SPrincipal TechnologistCommented:
I mean: String fileName = System.getProperty ( "windir" ) ;

BTW that is still Windows-specific code. Move the "windir" to a properties-file and read from there.
sree032397Author Commented:
No,
System.getProperty ( "windir" )
is giving null
sree032397Author Commented:
I am using JRE 1.4.2_03-b02
CEHJCommented:
Doesn't work on Java 1.4. You can Runtime.exec "cmd.exe /C echo %WINDIR%" on any version though

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mbvvsatishCommented:
mbvvsatishCommented:
from the command prompt if you run Test.java as specified below. it works, but i am not sure how far it is useful for you.
java -Dwindir=%windir% Test
CEHJCommented:
The method i mentioned is more tiresome than that, but less vulnerable. Let me know if you need to run on <= Win98
Mick BarryJava DeveloperCommented:
> java -Dwindir=%windir% Test

that is what you should be doing. You can then access the property uising

String windir = System.getProperty("windir");
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.