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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
object, "os.name"?
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?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
its the system property name that specifies the OS
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