Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Java detection on Server OS type

Posted on 2006-06-21
6
Medium Priority
?
236 Views
Last Modified: 2012-08-14
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.
0
Comment
Question by:xman19
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 92

Accepted Solution

by:
objects earned 1300 total points
ID: 16956807
String os = System.getProperty("os.name");
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 16956891
>> 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
0
 

Author Comment

by:xman19
ID: 16957117
object, "os.name"?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:xman19
ID: 16957133
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?
0
 
LVL 30

Assisted Solution

by:Mayank S
Mayank S earned 400 total points
ID: 16957156
The list of allowed System properties is available here:

http://java.sun.com/docs/books/tutorial/essential/system/properties.html
0
 
LVL 92

Expert Comment

by:objects
ID: 16957162
its the system property name that specifies the OS
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question