What is the best way to get the UNIX uptime in Java? Is there a standard Java library/function I could use or should I use Runtime's exec or ProcessBuilder to execute 'uptime'? Thanks
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
You can read
/proc/uptime
:From Wikipedia:
Did you try this? The only command that does something equivalent to
system('uptime');
in java isrunTime.exec()
. Thats all I could think of ..This is likely to be entirely system dependant but you can use
System.nanotime();
prints
Warning: This is unlikely to work on all platforms.