Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find the OS bit type [duplicate]

I want to know the OS type, means is it of 64bit os or 32bit os. But I am getting different response from 32bit/64bit executable which getting system properties about OS

I am getting details from system property. and I have 64bit machine and OS windows 8.1 X64

        "OS Architecture : " + System.getProperty("os.arch"));

        "OS Name : " + System.getProperty("os.name"));

        "OS Version : " + System.getProperty("os.version")

        "Data Model : " + System.getProperty("sun.arch.data.model"));


While running 64bit Executable getting following response.


OS Architecture : amd64

OS Name : Windows 8

OS Version : 6.2 amd64

Data Model : 64


While running 32bit Executable getting following response.


OS Architecture : x86

OS Name : Windows 8

OS Version : 6.2 x86

Data Model : 32


How can I get OS actual bit type ?

like image 505
Tej Kiran Avatar asked Dec 31 '13 11:12

Tej Kiran


People also ask

How can I tell if my operating system is 32-bit or 64-bit?

Look for "lm" in the command output. If lm is found in the output, then the CPU is 64-bit. If you don't see lm or see i386, i486, i586, or i686 in the output, then the CPU is 32-bit.

How do I find my OS bit rate?

Click Start, type system in the search box, and then click System in the Control Panel list. The operating system is displayed as follows: For a 64-bit version operating system: 64-bit Operating System appears for the System type under System.


2 Answers

System.getProperty("os.arch") will always return the bit type of the jre and not of the actual operating system.

Write jni code and calll IsWow64Process from winapi. Since you are using windows.

This boolean function tells you whether the process is running on 64-bit os.

like image 92
Sorter Avatar answered Oct 23 '22 21:10

Sorter


This should help you

System.getProperty("os.arch");

will return "x86" when the architecture of JRE is 32 bit. We have to write native code to get the real architecture of the system using JNI.

like image 22
Keerthivasan Avatar answered Oct 23 '22 20:10

Keerthivasan