Reputation: 4824
Using Java 6 in OSX, how can I determine if the current hardware is a Desktop or a Laptop? I was looking through System.getProperty()
, but didn't find anything definitive.
Upvotes: 2
Views: 1220
Reputation: 205885
You can query ioreg
for the model
via ProcessBuilder
, as shown here.
Addendum: Similar information may be obtained from the output of system_profiler
.
Upvotes: 2
Reputation:
You can use standard Unix tools to discover some of the information you may need to make this determination.
Here is an example from my machine:
>[jhr@Blackintosh] system_profiler SPHardwareDataType
Hardware Overview:
Model Name: Mac Pro
Model Identifier: MacPro3,1
Processor Name: Quad-Core Intel Xeon
Processor Speed: 2.33 GHz
Number of Processors: 1
Total Number of Cores: 4
L2 Cache: 4 MB
Memory: 8 GB
Bus Speed: 1.33 GHz
Boot ROM Version: MP31.006C.B05
SMC Version (system): 1.30f3
Serial Number (system): G8819IY0XYK
Hardware UUID: 8F6CD4F7-BA8F-5564-84DA-55A5AC59D42E
The Model Identifier:
tells you exactly what model of hardware is being used.
It would be a simple exercise to exec()
the command system_profiler SPHardwareDataType
and parse the response line by line and get what you need.
system_profiler
without any arguments gives you ever detail about the machine and the OS.
Upvotes: 1
Reputation: 2295
This info is not readily available to Java. You'll probably have to call to a native library to obtain that information. Here's a question that deals with that problem: Getting the Machine Type and other Hardware details through Cocoa API
Upvotes: 1