Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java - How can i determine the running Mac OS X version with code? [duplicate]

Possible Duplicate:
Finding the version of OSX inside java

I want to check the current Mac OS X version my Java application is running on using Java code. Specifically, i want to know if this is Lion or not.

That way i can determine if to use a library or not.

like image 861
Brad Avatar asked Sep 17 '12 20:09

Brad


People also ask

How do you determine about the software version on a Mac?

From the Apple menu  in the corner of your screen, choose About This Mac. You should see the macOS name, such as macOS Monterey or macOS Big Sur, followed by its version number. If you need to know the build number as well, click the version number to see it.

How do I find my JDK path on Mac?

In macOS, the JDK installation path is /Library/Java/JavaVirtualMachines/jdk-10. jdk/Contents/Home . The root directory of the JDK software installation.

How do I change Java version on Mac?

First, we need to change the current directory to /usr/libexec using the cd command. Once we are in the /usr/libexec directory, we execute the ./java_home command with -V that returns the versions and locations of the installed Java. Here is the output after running the command.


3 Answers

Use:

System.getProperty("os.name") // Yields "Mac OS X"
System.getProperty("os.version") // Yields "10.7.4" for me on Lion
like image 147
Marcus Adams Avatar answered Oct 28 '22 01:10

Marcus Adams


You can look at the system property os.version http://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html

like image 43
Stephen P Avatar answered Oct 28 '22 02:10

Stephen P


Did you try the following:

System.getProperty("os.name");

You can find more details at "System Properties".

like image 37
AAT Avatar answered Oct 28 '22 01:10

AAT