0

I have a Java application that is a wrapper for a different application (which requires >=SSE4_1 to be supported).

Because of this, I want to be able to detect the avaible CPU Features (Instruction Sets) in my Java application. I have not yet found a solution on how to do this in Java, one workaround would be using googles "cpu_features" C Library and creating a simple helper tool that exits with 0 or 1. But that would also require me to compile the C application for all platforms and isn't really an elegant solution. On linux you could cat /proc/cpuinfo for this, but not on Windows.

And then there is also a difference in the avaible Features on the CPU and the ones that are actually supported by the OS (which is the result you need).

Could someone give me a guiding hand here? Thank you in advance!

  • Maybe you are using the wrong tool for your purpose. Java is designed to run on every platform, hardware independently, as long a JVM can be run on the platform. Doing CPU dependent things is for sure not the thing java is suitable for. – Heri Nov 24 '19 at 15:55

1 Answers1

2

There isn't a cross-platform way to do this in pure Java. (Even ignoring that x86 flags make no sense on non-Intel / AMD platforms!)

The cpu_features library that you have already found is the best that you are likely to get. And as you noted, this will require either a separate application executable for each platform, or a native library / DLL built for each platform.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216