Languages

Java check if linux is current operating system / detect os

4 points
Asked by:
illona
526

How can I detect if I run my java application on Linux operating system?

I want to ensure I am on Linux before I try to read the file from Linux path:

 

2 answers
4 points
Answered by:
Root-ssh
178180

We can use commons-lang3 library:

Maven dependency:

Source: https://mvnrepository.com/artifact/org.apache.commons/commons-lang3/3.12.0

 

References

  1. Java - detect operating system name (Windows, Linux, macOS)
0 commentsAdd comment
3 points
Answered by:
Root-ssh
178180

Custom solution:

0 commentsAdd comment
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join