Link to home
Start Free TrialLog in
Avatar of xman19
xman19

asked on

Java detection on Server OS type

Hi, my application potentially will be running on UNIX, ,LINUX, or Window OS.

I am wondering is JAva able to detect which OS i am currently running. I am asking this because sometime my application will neeed to access the location machine directory. For UNIX or FreeBSD the file structure is different comparing with window.

So, i plan to put a if-else condition to check what is the OS i am using so that i can access the directory respectively.

thanks.
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>> i plan to put a if-else condition to check what is the OS i am using so that i can access the directory respectively

You should ideally put the directory-name in a properties-file so that it can be changed at run-time without modifying the code, rather than hard-code for only certain scenarios in the code.

http://www.javaalmanac.com/egs/java.util/Props.html
Avatar of xman19
xman19

ASKER

object, "os.name"?
Avatar of xman19

ASKER

yeah. it;s working and its printing Window XP for me.

I am wondering any other words other than "os.name"?

first look at it, unbeliable it's passing the "os.name" into it. Do i have "os.file"? or "os.yearmanafacture"? or things like that?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
its the system property name that specifies the OS