javaoperating-systemjnotify

How to understand which os are we on?


I am listening some path in a computer by using JNotify api. But since watching the file system is a relatively low level thing it uses different libraries for different operating systems, such as linux, mac or windows. and 32, 64 bit makes difference too. my question is how to select which library to use. when I add all of them to the build path, it causes error. i need some configurations i think but I dont know how:/ any help would be appreciated. btw I use java on eclipse.


Solution

  • You can find out what platform you are running on using the os.arch/os.name system property. See this answer to a similar question for more details.

    As for loading the correct library, you could package each of the platform specific classes into their own jar and load them dynamically. See this question for an example of that.