1

Is there any way to get time since system boot for mac os x in java?

In Visual studio we have gettickcount function but in java I am not able to get which function can do the same..

I dont want to implement it manually using timer that will be last option So is there any api function for that.

Bharat Sharma
  • 3,926
  • 2
  • 17
  • 29
  • 4
    What feature are you attempting to offer the user? And.. *"system boot time for mac os x in java swing"* Why do you think 'system boot time' is in ***any*** way related to Swing? – Andrew Thompson Apr 02 '13 at 07:16
  • how about parsing the `/Applications/Utilities/system.log` ? – Raptor Apr 02 '13 at 07:18
  • It is not related to swing but as swing provided several api's to interact with os and i am currently working on swing so is there any way to get it in swing. Actually i want to know any timestamp which will accurate and will not change according to system time. using boot time i can calculate difference between previous stored boot time difference in my application and current boot time difference in my system and use it. – Bharat Sharma Apr 02 '13 at 07:23
  • 1
    Is `uptime` available on Mac OS X? If so, maybe you could run that and parse the output. – mthmulders Apr 02 '13 at 07:23
  • I am editing my question again so that it can more clear to every one. – Bharat Sharma Apr 02 '13 at 07:26
  • @AndrewThompson Instead of such a useless reply you can give me a direction sir. – Bharat Sharma Apr 02 '13 at 07:44

2 Answers2

1

Via JNI you can have all API from OS

  • @BharatSharma maybe this one : http://stackoverflow.com/a/11676260/529543 or http://stackoverflow.com/a/11676260/529543, but you know the idea: JNI and you have everthing in Swing from OS –  Apr 02 '13 at 08:07
  • JNI idea i am having already . But again if i want time since system boot then it will depend on current system time which can be changed. So, time since boot will also change because it will be the difference between current time and last boot time. – Bharat Sharma Apr 02 '13 at 08:41
1

AFAIK there is no direct API for this. You can either execute a system utility program which will return you this value or can use JNI to achieve this.

Brad Werth
  • 17,411
  • 10
  • 63
  • 88
Sachin Gorade
  • 1,427
  • 12
  • 32