How can I tell if I'm running in 64-bit JVM or 32-bit JVM (from within a program)?
How can I tell if the JVM in which my application runs is 32 bit or 64-bit? Specifically, what functions or properties I can used to detect this within the program?
java jvm java-native-interface 64bit 32-bit
|
show 5 more comments
How can I tell if the JVM in which my application runs is 32 bit or 64-bit? Specifically, what functions or properties I can used to detect this within the program?
java jvm java-native-interface 64bit 32-bit
3
Just out of curiosity, why would you need to know the natural size of the system? Details such as this are abstracted away in Java, so you shouldn't (in theory, at least) have to know them.
– Patrick Niedzielski
Jan 14 '10 at 4:29
3
It lets me roughly estimate the memory requirements for objects due to pointers. Curiosity too -- seemed like there should be a way, but I'd never heard of it.
– BobMcGee
Jan 14 '10 at 18:33
81
This "detail" is not abstracted away when interacting with the Java Native Interface. 32-bit DLLs can't be loaded with a 64-bit JVM (and vice versa). So this is quite essential information for anyone using JNI. It's a pity that there seems to be no portable way to obtain this info. One way is to first try loading a 32-bit version of the DLL, and if it fails, try the 64-bit version, etc. Ugly!
– Joonas Pulakka
Apr 30 '10 at 7:17
11
Another situation where discerning between 32 or 64 bit JVMs is important is for mapped files. On 32 bit systems only 2GB can be mapped, so it's important to map and unmap file segments accordingly so that this limit is not exceeded, while on 64 bit jvms the limit is much, much, much higher.
– Simone Gianni
Sep 9 '12 at 21:07
2
It's really nice to be able to choose the numerical algorithm that will be fastest on the machine in question.
– dfeuer
Apr 22 '14 at 18:09
|
show 5 more comments
How can I tell if the JVM in which my application runs is 32 bit or 64-bit? Specifically, what functions or properties I can used to detect this within the program?
java jvm java-native-interface 64bit 32-bit
How can I tell if the JVM in which my application runs is 32 bit or 64-bit? Specifically, what functions or properties I can used to detect this within the program?
java jvm java-native-interface 64bit 32-bit
java jvm java-native-interface 64bit 32-bit
edited Mar 23 at 7:29
Hearen
2,88511430
2,88511430
asked Jan 14 '10 at 3:38
BobMcGeeBobMcGee
13.5k73754
13.5k73754
3
Just out of curiosity, why would you need to know the natural size of the system? Details such as this are abstracted away in Java, so you shouldn't (in theory, at least) have to know them.
– Patrick Niedzielski
Jan 14 '10 at 4:29
3
It lets me roughly estimate the memory requirements for objects due to pointers. Curiosity too -- seemed like there should be a way, but I'd never heard of it.
– BobMcGee
Jan 14 '10 at 18:33
81
This "detail" is not abstracted away when interacting with the Java Native Interface. 32-bit DLLs can't be loaded with a 64-bit JVM (and vice versa). So this is quite essential information for anyone using JNI. It's a pity that there seems to be no portable way to obtain this info. One way is to first try loading a 32-bit version of the DLL, and if it fails, try the 64-bit version, etc. Ugly!
– Joonas Pulakka
Apr 30 '10 at 7:17
11
Another situation where discerning between 32 or 64 bit JVMs is important is for mapped files. On 32 bit systems only 2GB can be mapped, so it's important to map and unmap file segments accordingly so that this limit is not exceeded, while on 64 bit jvms the limit is much, much, much higher.
– Simone Gianni
Sep 9 '12 at 21:07
2
It's really nice to be able to choose the numerical algorithm that will be fastest on the machine in question.
– dfeuer
Apr 22 '14 at 18:09
|
show 5 more comments
3
Just out of curiosity, why would you need to know the natural size of the system? Details such as this are abstracted away in Java, so you shouldn't (in theory, at least) have to know them.
– Patrick Niedzielski
Jan 14 '10 at 4:29
3
It lets me roughly estimate the memory requirements for objects due to pointers. Curiosity too -- seemed like there should be a way, but I'd never heard of it.
– BobMcGee
Jan 14 '10 at 18:33
81
This "detail" is not abstracted away when interacting with the Java Native Interface. 32-bit DLLs can't be loaded with a 64-bit JVM (and vice versa). So this is quite essential information for anyone using JNI. It's a pity that there seems to be no portable way to obtain this info. One way is to first try loading a 32-bit version of the DLL, and if it fails, try the 64-bit version, etc. Ugly!
– Joonas Pulakka
Apr 30 '10 at 7:17
11
Another situation where discerning between 32 or 64 bit JVMs is important is for mapped files. On 32 bit systems only 2GB can be mapped, so it's important to map and unmap file segments accordingly so that this limit is not exceeded, while on 64 bit jvms the limit is much, much, much higher.
– Simone Gianni
Sep 9 '12 at 21:07
2
It's really nice to be able to choose the numerical algorithm that will be fastest on the machine in question.
– dfeuer
Apr 22 '14 at 18:09
3
3
Just out of curiosity, why would you need to know the natural size of the system? Details such as this are abstracted away in Java, so you shouldn't (in theory, at least) have to know them.
– Patrick Niedzielski
Jan 14 '10 at 4:29
Just out of curiosity, why would you need to know the natural size of the system? Details such as this are abstracted away in Java, so you shouldn't (in theory, at least) have to know them.
– Patrick Niedzielski
Jan 14 '10 at 4:29
3
3
It lets me roughly estimate the memory requirements for objects due to pointers. Curiosity too -- seemed like there should be a way, but I'd never heard of it.
– BobMcGee
Jan 14 '10 at 18:33
It lets me roughly estimate the memory requirements for objects due to pointers. Curiosity too -- seemed like there should be a way, but I'd never heard of it.
– BobMcGee
Jan 14 '10 at 18:33
81
81
This "detail" is not abstracted away when interacting with the Java Native Interface. 32-bit DLLs can't be loaded with a 64-bit JVM (and vice versa). So this is quite essential information for anyone using JNI. It's a pity that there seems to be no portable way to obtain this info. One way is to first try loading a 32-bit version of the DLL, and if it fails, try the 64-bit version, etc. Ugly!
– Joonas Pulakka
Apr 30 '10 at 7:17
This "detail" is not abstracted away when interacting with the Java Native Interface. 32-bit DLLs can't be loaded with a 64-bit JVM (and vice versa). So this is quite essential information for anyone using JNI. It's a pity that there seems to be no portable way to obtain this info. One way is to first try loading a 32-bit version of the DLL, and if it fails, try the 64-bit version, etc. Ugly!
– Joonas Pulakka
Apr 30 '10 at 7:17
11
11
Another situation where discerning between 32 or 64 bit JVMs is important is for mapped files. On 32 bit systems only 2GB can be mapped, so it's important to map and unmap file segments accordingly so that this limit is not exceeded, while on 64 bit jvms the limit is much, much, much higher.
– Simone Gianni
Sep 9 '12 at 21:07
Another situation where discerning between 32 or 64 bit JVMs is important is for mapped files. On 32 bit systems only 2GB can be mapped, so it's important to map and unmap file segments accordingly so that this limit is not exceeded, while on 64 bit jvms the limit is much, much, much higher.
– Simone Gianni
Sep 9 '12 at 21:07
2
2
It's really nice to be able to choose the numerical algorithm that will be fastest on the machine in question.
– dfeuer
Apr 22 '14 at 18:09
It's really nice to be able to choose the numerical algorithm that will be fastest on the machine in question.
– dfeuer
Apr 22 '14 at 18:09
|
show 5 more comments
11 Answers
11
active
oldest
votes
Sun has a Java System property to determine the bitness of the JVM: 32 or 64:
sun.arch.data.model=32 // 32 bit JVM
sun.arch.data.model=64 // 64 bit JVM
You can use
System.getProperty("sun.arch.data.model")
to determine if its 32/64 from the program.
From the Sun HotSpot FAQ:
When writing Java code, how do I
distinguish between 32 and 64-bit
operation?
There's no public API that allows you
to distinguish between 32 and 64-bit
operation. Think of 64-bit as just
another platform in the write once,
run anywhere tradition. However, if
you'd like to write code which is
platform specific (shame on you), the
system propertysun.arch.data.model
has the value "32", "64", or
"unknown".
The only good reason is if your java
code is dependent upon native libraries
and your code needs to determine which
version (32 or 64bit) to load on startup.
21
I wouldn't expect to findsun.*system properties with an IBM JVM. In other words, it's not portable.
– Pascal Thivent
Jan 14 '10 at 23:19
8
How can you tell from the command line? If you are running 32-bit or 64-bit? Just curious.
– Xonatron
Feb 2 '12 at 20:33
17
Why is the accepted answer Sun-dependent? "os.arch" will accomplish the same thing without having to use proprietary sun packages.
– b1nary.atr0phy
May 24 '12 at 10:38
7
@b1naryatr0phy, does os.arch report on the Operating System, or the JVM? I often run 32-bit JVM on my 64-bit workstation, for development purposes.
– skiphoppy
Aug 8 '12 at 17:19
7
This property is supported on IBM JVMs, but not on GCJ. See stackoverflow.com/questions/807263/…
– Emmanuel Bourg
Nov 9 '12 at 13:13
|
show 6 more comments
You can try on the command line:
java -d64 -version
If it's not a 64-bit version, you'll get a message that looks like:
This Java instance does not support a 64-bit JVM.
Please install the desired version.
Consult the help options of the JVM for more info java -help
38
The -d64 flag works in Windows 7.
– Joshua Burns
Oct 20 '11 at 16:48
13
Exactly what I was looking for. And you can runjava -d32 -versionto verify you are not running 32-bit. Both wish work onWin7.
– Xonatron
Feb 2 '12 at 20:34
31
I am on Windows 7, and I get 'unrecognized option' error fromjava -d32 -versionand also fromjava -d64 -version.
– ely
Apr 20 '12 at 20:29
39
Do not use "-D64", for that does something completely different. It defines a system property called "64". This is definitely not what is wanted here.
– Jonathan Headland
Jul 30 '14 at 12:00
9
The -d32 or -d64 flags will only work for a Java 7 or greater.
– darrenmc
Aug 8 '14 at 10:41
|
show 12 more comments
Just type java -version in your console.
If a 64 bit version is running, you'll get a message like:
java version "1.6.0_18"
Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
Java HotSpot(TM) 64-Bit Server VM (build 16.0-b13, mixed mode)
A 32 bit version will show something similar to:
java version "1.6.0_41"
Java(TM) SE Runtime Environment (build 1.6.0_41-b02)
Java HotSpot(TM) Client VM (build 20.14-b01, mixed mode, sharing)
Note Client instead of 64-Bit Server in the third line. The Client/Server part is irrelevant, it's the absence of the 64-Bit that matters.
If multiple Java versions are installed on your system, navigate to the /bin folder of the Java version you want to check, and type java -version there.
but in hp nonstop oss env I'm not getting 64bit or 32 bit
– vels4j
Jul 23 '15 at 13:25
24
OP specifically says within the program.
– Tomáš Zato
Sep 21 '15 at 12:20
add a comment |
I installed 32-bit JVM and retried it again, looks like the following does tell you JVM bitness, not OS arch:
System.getProperty("os.arch");
#
# on a 64-bit Linux box:
# "x86" when using 32-bit JVM
# "amd64" when using 64-bit JVM
This was tested against both SUN and IBM JVM (32 and 64-bit). Clearly, the system property is not just the operating system arch.
7
This gives Operating system architecture info. If I'm not wrong, this need not be same of JVM bitness.
– codaddict
Jan 14 '10 at 3:52
2
@codaddict, looks like it is JVM bitness indeed.
– bryantsai
Jan 14 '10 at 23:14
20
@codaddict That is completely false (and I have no idea why six ppl have voted that comment up.) "os.arch" is designed to return the JVM version. Test it out for yourself and god help you if you're actually relying on this for OS detection.
– b1nary.atr0phy
May 24 '12 at 10:36
6
os.archhas many possible values, it's difficult to tell if it's 32 or 64 bits. See lopica.sourceforge.net/os.html
– Emmanuel Bourg
Nov 9 '12 at 13:15
2
This is a string intended for human eyes and without a strict definition of valid values, relying on this is not a good idea - write code that checks actual functionality instead.
– Thorbjørn Ravn Andersen
Jul 9 '13 at 22:34
|
show 3 more comments
Complementary info:
On a running process you may use (at least with some recent Sun JDK5/6 versions):
$ /opt/java1.5/bin/jinfo -sysprops 14680 | grep sun.arch.data.model
Attaching to process ID 14680, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 1.5.0_16-b02
sun.arch.data.model = 32
where 14680 is PID of jvm running the application. "os.arch" works too.
Also other scenarios are supported:
jinfo [ option ] pid
jinfo [ option ] executable core
jinfo [ option ] [server-id@]remote-hostname-or-IP
However consider also this note:
"NOTE - This utility is unsupported and may or may not be available in future versions of the JDK. In Windows Systems where dbgent.dll is not present, 'Debugging Tools for Windows' needs to be installed to have these tools working. Also the PATH environment variable should contain the location of jvm.dll used by the target process or the location from which the Crash Dump file was produced."
add a comment |
On Linux, you can get ELF header information by using either of the following two commands:
file {YOUR_JRE_LOCATION_HERE}/bin/java
o/p:
ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.4.0, dynamically linked (uses shared libs), for GNU/Linux 2.4.0, not stripped
or
readelf -h {YOUR_JRE_LOCATION_HERE}/bin/java | grep 'Class'
o/p:
Class: ELF64
add a comment |
If you are using JNA, you can check whether com.sun.jna.Native.POINTER_SIZE == 4 (32 bit) or com.sun.jna.Native.POINTER_SIZE == 8 (64 bit).
This is clever but accessing the pointer size is significantly slower than the other solutions here (it needs some time to initialize).
– BullyWiiPlaza
Aug 7 '18 at 20:44
add a comment |
Under Windows 7 in the "Control Panel" under "Programs | Programs and Features" the 64-bit variants of JRE & JDK are listed with "64-bit" in parentheses (e.g. "Java SE Development Kit 7 Update 65 (64-Bit)"), while for the 32-bit variants the variant is not mentioned in parentheses (e.g. just "Java SE Development Kit 8 Update 60").
add a comment |
For Windows, you can check the Java home location. If it contains (x86) it is 32-bit otherwise 64-bit:
public static boolean is32Bit()
{
val javaHome = System.getProperty("java.home");
return javaHome.contains("(x86)");
}
public static boolean is64Bit()
{
return !is32Bit();
}
Example paths:
C:Program Files (x86)Javajdk1.8.0_181binjava.exe # 32-bit
C:Program FilesJavajdk-10.0.2binjava.exe # 64-bit
Why care about a Windows only solution?
If you need to know which bit version you're running on, you're likely fiddling around with native code on Windows so platform-independence is out of the window anyway.
add a comment |
If you're using JNA, you can do thisPlatform.is64Bit().
add a comment |
To get the version of JVM currently running the program
System.out.println(Runtime.class.getPackage().getImplementationVersion());
Would that report for the JVM or the operating system? You can run a 32-bit JVM on a 64-bit operating system.
– Thorbjørn Ravn Andersen
Sep 24 '17 at 7:18
That doesn’t use JMX?
– Thorbjørn Ravn Andersen
Sep 24 '17 at 11:52
1
This returns something like1.8.0_172ornullonJava 10and doesn't answer the question anyway.
– BullyWiiPlaza
Aug 7 '18 at 21:08
add a comment |
protected by Community♦ Mar 23 at 7:47
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
11 Answers
11
active
oldest
votes
11 Answers
11
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sun has a Java System property to determine the bitness of the JVM: 32 or 64:
sun.arch.data.model=32 // 32 bit JVM
sun.arch.data.model=64 // 64 bit JVM
You can use
System.getProperty("sun.arch.data.model")
to determine if its 32/64 from the program.
From the Sun HotSpot FAQ:
When writing Java code, how do I
distinguish between 32 and 64-bit
operation?
There's no public API that allows you
to distinguish between 32 and 64-bit
operation. Think of 64-bit as just
another platform in the write once,
run anywhere tradition. However, if
you'd like to write code which is
platform specific (shame on you), the
system propertysun.arch.data.model
has the value "32", "64", or
"unknown".
The only good reason is if your java
code is dependent upon native libraries
and your code needs to determine which
version (32 or 64bit) to load on startup.
21
I wouldn't expect to findsun.*system properties with an IBM JVM. In other words, it's not portable.
– Pascal Thivent
Jan 14 '10 at 23:19
8
How can you tell from the command line? If you are running 32-bit or 64-bit? Just curious.
– Xonatron
Feb 2 '12 at 20:33
17
Why is the accepted answer Sun-dependent? "os.arch" will accomplish the same thing without having to use proprietary sun packages.
– b1nary.atr0phy
May 24 '12 at 10:38
7
@b1naryatr0phy, does os.arch report on the Operating System, or the JVM? I often run 32-bit JVM on my 64-bit workstation, for development purposes.
– skiphoppy
Aug 8 '12 at 17:19
7
This property is supported on IBM JVMs, but not on GCJ. See stackoverflow.com/questions/807263/…
– Emmanuel Bourg
Nov 9 '12 at 13:13
|
show 6 more comments
Sun has a Java System property to determine the bitness of the JVM: 32 or 64:
sun.arch.data.model=32 // 32 bit JVM
sun.arch.data.model=64 // 64 bit JVM
You can use
System.getProperty("sun.arch.data.model")
to determine if its 32/64 from the program.
From the Sun HotSpot FAQ:
When writing Java code, how do I
distinguish between 32 and 64-bit
operation?
There's no public API that allows you
to distinguish between 32 and 64-bit
operation. Think of 64-bit as just
another platform in the write once,
run anywhere tradition. However, if
you'd like to write code which is
platform specific (shame on you), the
system propertysun.arch.data.model
has the value "32", "64", or
"unknown".
The only good reason is if your java
code is dependent upon native libraries
and your code needs to determine which
version (32 or 64bit) to load on startup.
21
I wouldn't expect to findsun.*system properties with an IBM JVM. In other words, it's not portable.
– Pascal Thivent
Jan 14 '10 at 23:19
8
How can you tell from the command line? If you are running 32-bit or 64-bit? Just curious.
– Xonatron
Feb 2 '12 at 20:33
17
Why is the accepted answer Sun-dependent? "os.arch" will accomplish the same thing without having to use proprietary sun packages.
– b1nary.atr0phy
May 24 '12 at 10:38
7
@b1naryatr0phy, does os.arch report on the Operating System, or the JVM? I often run 32-bit JVM on my 64-bit workstation, for development purposes.
– skiphoppy
Aug 8 '12 at 17:19
7
This property is supported on IBM JVMs, but not on GCJ. See stackoverflow.com/questions/807263/…
– Emmanuel Bourg
Nov 9 '12 at 13:13
|
show 6 more comments
Sun has a Java System property to determine the bitness of the JVM: 32 or 64:
sun.arch.data.model=32 // 32 bit JVM
sun.arch.data.model=64 // 64 bit JVM
You can use
System.getProperty("sun.arch.data.model")
to determine if its 32/64 from the program.
From the Sun HotSpot FAQ:
When writing Java code, how do I
distinguish between 32 and 64-bit
operation?
There's no public API that allows you
to distinguish between 32 and 64-bit
operation. Think of 64-bit as just
another platform in the write once,
run anywhere tradition. However, if
you'd like to write code which is
platform specific (shame on you), the
system propertysun.arch.data.model
has the value "32", "64", or
"unknown".
The only good reason is if your java
code is dependent upon native libraries
and your code needs to determine which
version (32 or 64bit) to load on startup.
Sun has a Java System property to determine the bitness of the JVM: 32 or 64:
sun.arch.data.model=32 // 32 bit JVM
sun.arch.data.model=64 // 64 bit JVM
You can use
System.getProperty("sun.arch.data.model")
to determine if its 32/64 from the program.
From the Sun HotSpot FAQ:
When writing Java code, how do I
distinguish between 32 and 64-bit
operation?
There's no public API that allows you
to distinguish between 32 and 64-bit
operation. Think of 64-bit as just
another platform in the write once,
run anywhere tradition. However, if
you'd like to write code which is
platform specific (shame on you), the
system propertysun.arch.data.model
has the value "32", "64", or
"unknown".
The only good reason is if your java
code is dependent upon native libraries
and your code needs to determine which
version (32 or 64bit) to load on startup.
edited Aug 18 '16 at 3:19
user207421
264k26215364
264k26215364
answered Jan 14 '10 at 3:44
codaddictcodaddict
354k64443493
354k64443493
21
I wouldn't expect to findsun.*system properties with an IBM JVM. In other words, it's not portable.
– Pascal Thivent
Jan 14 '10 at 23:19
8
How can you tell from the command line? If you are running 32-bit or 64-bit? Just curious.
– Xonatron
Feb 2 '12 at 20:33
17
Why is the accepted answer Sun-dependent? "os.arch" will accomplish the same thing without having to use proprietary sun packages.
– b1nary.atr0phy
May 24 '12 at 10:38
7
@b1naryatr0phy, does os.arch report on the Operating System, or the JVM? I often run 32-bit JVM on my 64-bit workstation, for development purposes.
– skiphoppy
Aug 8 '12 at 17:19
7
This property is supported on IBM JVMs, but not on GCJ. See stackoverflow.com/questions/807263/…
– Emmanuel Bourg
Nov 9 '12 at 13:13
|
show 6 more comments
21
I wouldn't expect to findsun.*system properties with an IBM JVM. In other words, it's not portable.
– Pascal Thivent
Jan 14 '10 at 23:19
8
How can you tell from the command line? If you are running 32-bit or 64-bit? Just curious.
– Xonatron
Feb 2 '12 at 20:33
17
Why is the accepted answer Sun-dependent? "os.arch" will accomplish the same thing without having to use proprietary sun packages.
– b1nary.atr0phy
May 24 '12 at 10:38
7
@b1naryatr0phy, does os.arch report on the Operating System, or the JVM? I often run 32-bit JVM on my 64-bit workstation, for development purposes.
– skiphoppy
Aug 8 '12 at 17:19
7
This property is supported on IBM JVMs, but not on GCJ. See stackoverflow.com/questions/807263/…
– Emmanuel Bourg
Nov 9 '12 at 13:13
21
21
I wouldn't expect to find
sun.* system properties with an IBM JVM. In other words, it's not portable.– Pascal Thivent
Jan 14 '10 at 23:19
I wouldn't expect to find
sun.* system properties with an IBM JVM. In other words, it's not portable.– Pascal Thivent
Jan 14 '10 at 23:19
8
8
How can you tell from the command line? If you are running 32-bit or 64-bit? Just curious.
– Xonatron
Feb 2 '12 at 20:33
How can you tell from the command line? If you are running 32-bit or 64-bit? Just curious.
– Xonatron
Feb 2 '12 at 20:33
17
17
Why is the accepted answer Sun-dependent? "os.arch" will accomplish the same thing without having to use proprietary sun packages.
– b1nary.atr0phy
May 24 '12 at 10:38
Why is the accepted answer Sun-dependent? "os.arch" will accomplish the same thing without having to use proprietary sun packages.
– b1nary.atr0phy
May 24 '12 at 10:38
7
7
@b1naryatr0phy, does os.arch report on the Operating System, or the JVM? I often run 32-bit JVM on my 64-bit workstation, for development purposes.
– skiphoppy
Aug 8 '12 at 17:19
@b1naryatr0phy, does os.arch report on the Operating System, or the JVM? I often run 32-bit JVM on my 64-bit workstation, for development purposes.
– skiphoppy
Aug 8 '12 at 17:19
7
7
This property is supported on IBM JVMs, but not on GCJ. See stackoverflow.com/questions/807263/…
– Emmanuel Bourg
Nov 9 '12 at 13:13
This property is supported on IBM JVMs, but not on GCJ. See stackoverflow.com/questions/807263/…
– Emmanuel Bourg
Nov 9 '12 at 13:13
|
show 6 more comments
You can try on the command line:
java -d64 -version
If it's not a 64-bit version, you'll get a message that looks like:
This Java instance does not support a 64-bit JVM.
Please install the desired version.
Consult the help options of the JVM for more info java -help
38
The -d64 flag works in Windows 7.
– Joshua Burns
Oct 20 '11 at 16:48
13
Exactly what I was looking for. And you can runjava -d32 -versionto verify you are not running 32-bit. Both wish work onWin7.
– Xonatron
Feb 2 '12 at 20:34
31
I am on Windows 7, and I get 'unrecognized option' error fromjava -d32 -versionand also fromjava -d64 -version.
– ely
Apr 20 '12 at 20:29
39
Do not use "-D64", for that does something completely different. It defines a system property called "64". This is definitely not what is wanted here.
– Jonathan Headland
Jul 30 '14 at 12:00
9
The -d32 or -d64 flags will only work for a Java 7 or greater.
– darrenmc
Aug 8 '14 at 10:41
|
show 12 more comments
You can try on the command line:
java -d64 -version
If it's not a 64-bit version, you'll get a message that looks like:
This Java instance does not support a 64-bit JVM.
Please install the desired version.
Consult the help options of the JVM for more info java -help
38
The -d64 flag works in Windows 7.
– Joshua Burns
Oct 20 '11 at 16:48
13
Exactly what I was looking for. And you can runjava -d32 -versionto verify you are not running 32-bit. Both wish work onWin7.
– Xonatron
Feb 2 '12 at 20:34
31
I am on Windows 7, and I get 'unrecognized option' error fromjava -d32 -versionand also fromjava -d64 -version.
– ely
Apr 20 '12 at 20:29
39
Do not use "-D64", for that does something completely different. It defines a system property called "64". This is definitely not what is wanted here.
– Jonathan Headland
Jul 30 '14 at 12:00
9
The -d32 or -d64 flags will only work for a Java 7 or greater.
– darrenmc
Aug 8 '14 at 10:41
|
show 12 more comments
You can try on the command line:
java -d64 -version
If it's not a 64-bit version, you'll get a message that looks like:
This Java instance does not support a 64-bit JVM.
Please install the desired version.
Consult the help options of the JVM for more info java -help
You can try on the command line:
java -d64 -version
If it's not a 64-bit version, you'll get a message that looks like:
This Java instance does not support a 64-bit JVM.
Please install the desired version.
Consult the help options of the JVM for more info java -help
edited Oct 3 '12 at 12:41
answered Jan 14 '10 at 5:00
gpamparagpampara
10.6k32126
10.6k32126
38
The -d64 flag works in Windows 7.
– Joshua Burns
Oct 20 '11 at 16:48
13
Exactly what I was looking for. And you can runjava -d32 -versionto verify you are not running 32-bit. Both wish work onWin7.
– Xonatron
Feb 2 '12 at 20:34
31
I am on Windows 7, and I get 'unrecognized option' error fromjava -d32 -versionand also fromjava -d64 -version.
– ely
Apr 20 '12 at 20:29
39
Do not use "-D64", for that does something completely different. It defines a system property called "64". This is definitely not what is wanted here.
– Jonathan Headland
Jul 30 '14 at 12:00
9
The -d32 or -d64 flags will only work for a Java 7 or greater.
– darrenmc
Aug 8 '14 at 10:41
|
show 12 more comments
38
The -d64 flag works in Windows 7.
– Joshua Burns
Oct 20 '11 at 16:48
13
Exactly what I was looking for. And you can runjava -d32 -versionto verify you are not running 32-bit. Both wish work onWin7.
– Xonatron
Feb 2 '12 at 20:34
31
I am on Windows 7, and I get 'unrecognized option' error fromjava -d32 -versionand also fromjava -d64 -version.
– ely
Apr 20 '12 at 20:29
39
Do not use "-D64", for that does something completely different. It defines a system property called "64". This is definitely not what is wanted here.
– Jonathan Headland
Jul 30 '14 at 12:00
9
The -d32 or -d64 flags will only work for a Java 7 or greater.
– darrenmc
Aug 8 '14 at 10:41
38
38
The -d64 flag works in Windows 7.
– Joshua Burns
Oct 20 '11 at 16:48
The -d64 flag works in Windows 7.
– Joshua Burns
Oct 20 '11 at 16:48
13
13
Exactly what I was looking for. And you can run
java -d32 -version to verify you are not running 32-bit. Both wish work on Win7.– Xonatron
Feb 2 '12 at 20:34
Exactly what I was looking for. And you can run
java -d32 -version to verify you are not running 32-bit. Both wish work on Win7.– Xonatron
Feb 2 '12 at 20:34
31
31
I am on Windows 7, and I get 'unrecognized option' error from
java -d32 -version and also from java -d64 -version.– ely
Apr 20 '12 at 20:29
I am on Windows 7, and I get 'unrecognized option' error from
java -d32 -version and also from java -d64 -version.– ely
Apr 20 '12 at 20:29
39
39
Do not use "-D64", for that does something completely different. It defines a system property called "64". This is definitely not what is wanted here.
– Jonathan Headland
Jul 30 '14 at 12:00
Do not use "-D64", for that does something completely different. It defines a system property called "64". This is definitely not what is wanted here.
– Jonathan Headland
Jul 30 '14 at 12:00
9
9
The -d32 or -d64 flags will only work for a Java 7 or greater.
– darrenmc
Aug 8 '14 at 10:41
The -d32 or -d64 flags will only work for a Java 7 or greater.
– darrenmc
Aug 8 '14 at 10:41
|
show 12 more comments
Just type java -version in your console.
If a 64 bit version is running, you'll get a message like:
java version "1.6.0_18"
Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
Java HotSpot(TM) 64-Bit Server VM (build 16.0-b13, mixed mode)
A 32 bit version will show something similar to:
java version "1.6.0_41"
Java(TM) SE Runtime Environment (build 1.6.0_41-b02)
Java HotSpot(TM) Client VM (build 20.14-b01, mixed mode, sharing)
Note Client instead of 64-Bit Server in the third line. The Client/Server part is irrelevant, it's the absence of the 64-Bit that matters.
If multiple Java versions are installed on your system, navigate to the /bin folder of the Java version you want to check, and type java -version there.
but in hp nonstop oss env I'm not getting 64bit or 32 bit
– vels4j
Jul 23 '15 at 13:25
24
OP specifically says within the program.
– Tomáš Zato
Sep 21 '15 at 12:20
add a comment |
Just type java -version in your console.
If a 64 bit version is running, you'll get a message like:
java version "1.6.0_18"
Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
Java HotSpot(TM) 64-Bit Server VM (build 16.0-b13, mixed mode)
A 32 bit version will show something similar to:
java version "1.6.0_41"
Java(TM) SE Runtime Environment (build 1.6.0_41-b02)
Java HotSpot(TM) Client VM (build 20.14-b01, mixed mode, sharing)
Note Client instead of 64-Bit Server in the third line. The Client/Server part is irrelevant, it's the absence of the 64-Bit that matters.
If multiple Java versions are installed on your system, navigate to the /bin folder of the Java version you want to check, and type java -version there.
but in hp nonstop oss env I'm not getting 64bit or 32 bit
– vels4j
Jul 23 '15 at 13:25
24
OP specifically says within the program.
– Tomáš Zato
Sep 21 '15 at 12:20
add a comment |
Just type java -version in your console.
If a 64 bit version is running, you'll get a message like:
java version "1.6.0_18"
Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
Java HotSpot(TM) 64-Bit Server VM (build 16.0-b13, mixed mode)
A 32 bit version will show something similar to:
java version "1.6.0_41"
Java(TM) SE Runtime Environment (build 1.6.0_41-b02)
Java HotSpot(TM) Client VM (build 20.14-b01, mixed mode, sharing)
Note Client instead of 64-Bit Server in the third line. The Client/Server part is irrelevant, it's the absence of the 64-Bit that matters.
If multiple Java versions are installed on your system, navigate to the /bin folder of the Java version you want to check, and type java -version there.
Just type java -version in your console.
If a 64 bit version is running, you'll get a message like:
java version "1.6.0_18"
Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
Java HotSpot(TM) 64-Bit Server VM (build 16.0-b13, mixed mode)
A 32 bit version will show something similar to:
java version "1.6.0_41"
Java(TM) SE Runtime Environment (build 1.6.0_41-b02)
Java HotSpot(TM) Client VM (build 20.14-b01, mixed mode, sharing)
Note Client instead of 64-Bit Server in the third line. The Client/Server part is irrelevant, it's the absence of the 64-Bit that matters.
If multiple Java versions are installed on your system, navigate to the /bin folder of the Java version you want to check, and type java -version there.
edited May 4 '15 at 10:34
Sergei Tachenov
18.4k44359
18.4k44359
answered Jun 3 '11 at 20:58
Sedat KilincSedat Kilinc
2,38211719
2,38211719
but in hp nonstop oss env I'm not getting 64bit or 32 bit
– vels4j
Jul 23 '15 at 13:25
24
OP specifically says within the program.
– Tomáš Zato
Sep 21 '15 at 12:20
add a comment |
but in hp nonstop oss env I'm not getting 64bit or 32 bit
– vels4j
Jul 23 '15 at 13:25
24
OP specifically says within the program.
– Tomáš Zato
Sep 21 '15 at 12:20
but in hp nonstop oss env I'm not getting 64bit or 32 bit
– vels4j
Jul 23 '15 at 13:25
but in hp nonstop oss env I'm not getting 64bit or 32 bit
– vels4j
Jul 23 '15 at 13:25
24
24
OP specifically says within the program.
– Tomáš Zato
Sep 21 '15 at 12:20
OP specifically says within the program.
– Tomáš Zato
Sep 21 '15 at 12:20
add a comment |
I installed 32-bit JVM and retried it again, looks like the following does tell you JVM bitness, not OS arch:
System.getProperty("os.arch");
#
# on a 64-bit Linux box:
# "x86" when using 32-bit JVM
# "amd64" when using 64-bit JVM
This was tested against both SUN and IBM JVM (32 and 64-bit). Clearly, the system property is not just the operating system arch.
7
This gives Operating system architecture info. If I'm not wrong, this need not be same of JVM bitness.
– codaddict
Jan 14 '10 at 3:52
2
@codaddict, looks like it is JVM bitness indeed.
– bryantsai
Jan 14 '10 at 23:14
20
@codaddict That is completely false (and I have no idea why six ppl have voted that comment up.) "os.arch" is designed to return the JVM version. Test it out for yourself and god help you if you're actually relying on this for OS detection.
– b1nary.atr0phy
May 24 '12 at 10:36
6
os.archhas many possible values, it's difficult to tell if it's 32 or 64 bits. See lopica.sourceforge.net/os.html
– Emmanuel Bourg
Nov 9 '12 at 13:15
2
This is a string intended for human eyes and without a strict definition of valid values, relying on this is not a good idea - write code that checks actual functionality instead.
– Thorbjørn Ravn Andersen
Jul 9 '13 at 22:34
|
show 3 more comments
I installed 32-bit JVM and retried it again, looks like the following does tell you JVM bitness, not OS arch:
System.getProperty("os.arch");
#
# on a 64-bit Linux box:
# "x86" when using 32-bit JVM
# "amd64" when using 64-bit JVM
This was tested against both SUN and IBM JVM (32 and 64-bit). Clearly, the system property is not just the operating system arch.
7
This gives Operating system architecture info. If I'm not wrong, this need not be same of JVM bitness.
– codaddict
Jan 14 '10 at 3:52
2
@codaddict, looks like it is JVM bitness indeed.
– bryantsai
Jan 14 '10 at 23:14
20
@codaddict That is completely false (and I have no idea why six ppl have voted that comment up.) "os.arch" is designed to return the JVM version. Test it out for yourself and god help you if you're actually relying on this for OS detection.
– b1nary.atr0phy
May 24 '12 at 10:36
6
os.archhas many possible values, it's difficult to tell if it's 32 or 64 bits. See lopica.sourceforge.net/os.html
– Emmanuel Bourg
Nov 9 '12 at 13:15
2
This is a string intended for human eyes and without a strict definition of valid values, relying on this is not a good idea - write code that checks actual functionality instead.
– Thorbjørn Ravn Andersen
Jul 9 '13 at 22:34
|
show 3 more comments
I installed 32-bit JVM and retried it again, looks like the following does tell you JVM bitness, not OS arch:
System.getProperty("os.arch");
#
# on a 64-bit Linux box:
# "x86" when using 32-bit JVM
# "amd64" when using 64-bit JVM
This was tested against both SUN and IBM JVM (32 and 64-bit). Clearly, the system property is not just the operating system arch.
I installed 32-bit JVM and retried it again, looks like the following does tell you JVM bitness, not OS arch:
System.getProperty("os.arch");
#
# on a 64-bit Linux box:
# "x86" when using 32-bit JVM
# "amd64" when using 64-bit JVM
This was tested against both SUN and IBM JVM (32 and 64-bit). Clearly, the system property is not just the operating system arch.
edited Mar 23 at 7:30
Hearen
2,88511430
2,88511430
answered Jan 14 '10 at 3:47
bryantsaibryantsai
2,43012430
2,43012430
7
This gives Operating system architecture info. If I'm not wrong, this need not be same of JVM bitness.
– codaddict
Jan 14 '10 at 3:52
2
@codaddict, looks like it is JVM bitness indeed.
– bryantsai
Jan 14 '10 at 23:14
20
@codaddict That is completely false (and I have no idea why six ppl have voted that comment up.) "os.arch" is designed to return the JVM version. Test it out for yourself and god help you if you're actually relying on this for OS detection.
– b1nary.atr0phy
May 24 '12 at 10:36
6
os.archhas many possible values, it's difficult to tell if it's 32 or 64 bits. See lopica.sourceforge.net/os.html
– Emmanuel Bourg
Nov 9 '12 at 13:15
2
This is a string intended for human eyes and without a strict definition of valid values, relying on this is not a good idea - write code that checks actual functionality instead.
– Thorbjørn Ravn Andersen
Jul 9 '13 at 22:34
|
show 3 more comments
7
This gives Operating system architecture info. If I'm not wrong, this need not be same of JVM bitness.
– codaddict
Jan 14 '10 at 3:52
2
@codaddict, looks like it is JVM bitness indeed.
– bryantsai
Jan 14 '10 at 23:14
20
@codaddict That is completely false (and I have no idea why six ppl have voted that comment up.) "os.arch" is designed to return the JVM version. Test it out for yourself and god help you if you're actually relying on this for OS detection.
– b1nary.atr0phy
May 24 '12 at 10:36
6
os.archhas many possible values, it's difficult to tell if it's 32 or 64 bits. See lopica.sourceforge.net/os.html
– Emmanuel Bourg
Nov 9 '12 at 13:15
2
This is a string intended for human eyes and without a strict definition of valid values, relying on this is not a good idea - write code that checks actual functionality instead.
– Thorbjørn Ravn Andersen
Jul 9 '13 at 22:34
7
7
This gives Operating system architecture info. If I'm not wrong, this need not be same of JVM bitness.
– codaddict
Jan 14 '10 at 3:52
This gives Operating system architecture info. If I'm not wrong, this need not be same of JVM bitness.
– codaddict
Jan 14 '10 at 3:52
2
2
@codaddict, looks like it is JVM bitness indeed.
– bryantsai
Jan 14 '10 at 23:14
@codaddict, looks like it is JVM bitness indeed.
– bryantsai
Jan 14 '10 at 23:14
20
20
@codaddict That is completely false (and I have no idea why six ppl have voted that comment up.) "os.arch" is designed to return the JVM version. Test it out for yourself and god help you if you're actually relying on this for OS detection.
– b1nary.atr0phy
May 24 '12 at 10:36
@codaddict That is completely false (and I have no idea why six ppl have voted that comment up.) "os.arch" is designed to return the JVM version. Test it out for yourself and god help you if you're actually relying on this for OS detection.
– b1nary.atr0phy
May 24 '12 at 10:36
6
6
os.arch has many possible values, it's difficult to tell if it's 32 or 64 bits. See lopica.sourceforge.net/os.html– Emmanuel Bourg
Nov 9 '12 at 13:15
os.arch has many possible values, it's difficult to tell if it's 32 or 64 bits. See lopica.sourceforge.net/os.html– Emmanuel Bourg
Nov 9 '12 at 13:15
2
2
This is a string intended for human eyes and without a strict definition of valid values, relying on this is not a good idea - write code that checks actual functionality instead.
– Thorbjørn Ravn Andersen
Jul 9 '13 at 22:34
This is a string intended for human eyes and without a strict definition of valid values, relying on this is not a good idea - write code that checks actual functionality instead.
– Thorbjørn Ravn Andersen
Jul 9 '13 at 22:34
|
show 3 more comments
Complementary info:
On a running process you may use (at least with some recent Sun JDK5/6 versions):
$ /opt/java1.5/bin/jinfo -sysprops 14680 | grep sun.arch.data.model
Attaching to process ID 14680, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 1.5.0_16-b02
sun.arch.data.model = 32
where 14680 is PID of jvm running the application. "os.arch" works too.
Also other scenarios are supported:
jinfo [ option ] pid
jinfo [ option ] executable core
jinfo [ option ] [server-id@]remote-hostname-or-IP
However consider also this note:
"NOTE - This utility is unsupported and may or may not be available in future versions of the JDK. In Windows Systems where dbgent.dll is not present, 'Debugging Tools for Windows' needs to be installed to have these tools working. Also the PATH environment variable should contain the location of jvm.dll used by the target process or the location from which the Crash Dump file was produced."
add a comment |
Complementary info:
On a running process you may use (at least with some recent Sun JDK5/6 versions):
$ /opt/java1.5/bin/jinfo -sysprops 14680 | grep sun.arch.data.model
Attaching to process ID 14680, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 1.5.0_16-b02
sun.arch.data.model = 32
where 14680 is PID of jvm running the application. "os.arch" works too.
Also other scenarios are supported:
jinfo [ option ] pid
jinfo [ option ] executable core
jinfo [ option ] [server-id@]remote-hostname-or-IP
However consider also this note:
"NOTE - This utility is unsupported and may or may not be available in future versions of the JDK. In Windows Systems where dbgent.dll is not present, 'Debugging Tools for Windows' needs to be installed to have these tools working. Also the PATH environment variable should contain the location of jvm.dll used by the target process or the location from which the Crash Dump file was produced."
add a comment |
Complementary info:
On a running process you may use (at least with some recent Sun JDK5/6 versions):
$ /opt/java1.5/bin/jinfo -sysprops 14680 | grep sun.arch.data.model
Attaching to process ID 14680, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 1.5.0_16-b02
sun.arch.data.model = 32
where 14680 is PID of jvm running the application. "os.arch" works too.
Also other scenarios are supported:
jinfo [ option ] pid
jinfo [ option ] executable core
jinfo [ option ] [server-id@]remote-hostname-or-IP
However consider also this note:
"NOTE - This utility is unsupported and may or may not be available in future versions of the JDK. In Windows Systems where dbgent.dll is not present, 'Debugging Tools for Windows' needs to be installed to have these tools working. Also the PATH environment variable should contain the location of jvm.dll used by the target process or the location from which the Crash Dump file was produced."
Complementary info:
On a running process you may use (at least with some recent Sun JDK5/6 versions):
$ /opt/java1.5/bin/jinfo -sysprops 14680 | grep sun.arch.data.model
Attaching to process ID 14680, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 1.5.0_16-b02
sun.arch.data.model = 32
where 14680 is PID of jvm running the application. "os.arch" works too.
Also other scenarios are supported:
jinfo [ option ] pid
jinfo [ option ] executable core
jinfo [ option ] [server-id@]remote-hostname-or-IP
However consider also this note:
"NOTE - This utility is unsupported and may or may not be available in future versions of the JDK. In Windows Systems where dbgent.dll is not present, 'Debugging Tools for Windows' needs to be installed to have these tools working. Also the PATH environment variable should contain the location of jvm.dll used by the target process or the location from which the Crash Dump file was produced."
answered Feb 16 '12 at 19:04
dimdim
1,00221021
1,00221021
add a comment |
add a comment |
On Linux, you can get ELF header information by using either of the following two commands:
file {YOUR_JRE_LOCATION_HERE}/bin/java
o/p:
ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.4.0, dynamically linked (uses shared libs), for GNU/Linux 2.4.0, not stripped
or
readelf -h {YOUR_JRE_LOCATION_HERE}/bin/java | grep 'Class'
o/p:
Class: ELF64
add a comment |
On Linux, you can get ELF header information by using either of the following two commands:
file {YOUR_JRE_LOCATION_HERE}/bin/java
o/p:
ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.4.0, dynamically linked (uses shared libs), for GNU/Linux 2.4.0, not stripped
or
readelf -h {YOUR_JRE_LOCATION_HERE}/bin/java | grep 'Class'
o/p:
Class: ELF64
add a comment |
On Linux, you can get ELF header information by using either of the following two commands:
file {YOUR_JRE_LOCATION_HERE}/bin/java
o/p:
ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.4.0, dynamically linked (uses shared libs), for GNU/Linux 2.4.0, not stripped
or
readelf -h {YOUR_JRE_LOCATION_HERE}/bin/java | grep 'Class'
o/p:
Class: ELF64
On Linux, you can get ELF header information by using either of the following two commands:
file {YOUR_JRE_LOCATION_HERE}/bin/java
o/p:
ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.4.0, dynamically linked (uses shared libs), for GNU/Linux 2.4.0, not stripped
or
readelf -h {YOUR_JRE_LOCATION_HERE}/bin/java | grep 'Class'
o/p:
Class: ELF64
answered Jun 7 '12 at 8:50
jawsnnnjawsnnn
10814
10814
add a comment |
add a comment |
If you are using JNA, you can check whether com.sun.jna.Native.POINTER_SIZE == 4 (32 bit) or com.sun.jna.Native.POINTER_SIZE == 8 (64 bit).
This is clever but accessing the pointer size is significantly slower than the other solutions here (it needs some time to initialize).
– BullyWiiPlaza
Aug 7 '18 at 20:44
add a comment |
If you are using JNA, you can check whether com.sun.jna.Native.POINTER_SIZE == 4 (32 bit) or com.sun.jna.Native.POINTER_SIZE == 8 (64 bit).
This is clever but accessing the pointer size is significantly slower than the other solutions here (it needs some time to initialize).
– BullyWiiPlaza
Aug 7 '18 at 20:44
add a comment |
If you are using JNA, you can check whether com.sun.jna.Native.POINTER_SIZE == 4 (32 bit) or com.sun.jna.Native.POINTER_SIZE == 8 (64 bit).
If you are using JNA, you can check whether com.sun.jna.Native.POINTER_SIZE == 4 (32 bit) or com.sun.jna.Native.POINTER_SIZE == 8 (64 bit).
edited Jul 10 '17 at 12:32
roottraveller
4,20733644
4,20733644
answered Apr 10 '15 at 16:49
Anthony HaywardAnthony Hayward
8941011
8941011
This is clever but accessing the pointer size is significantly slower than the other solutions here (it needs some time to initialize).
– BullyWiiPlaza
Aug 7 '18 at 20:44
add a comment |
This is clever but accessing the pointer size is significantly slower than the other solutions here (it needs some time to initialize).
– BullyWiiPlaza
Aug 7 '18 at 20:44
This is clever but accessing the pointer size is significantly slower than the other solutions here (it needs some time to initialize).
– BullyWiiPlaza
Aug 7 '18 at 20:44
This is clever but accessing the pointer size is significantly slower than the other solutions here (it needs some time to initialize).
– BullyWiiPlaza
Aug 7 '18 at 20:44
add a comment |
Under Windows 7 in the "Control Panel" under "Programs | Programs and Features" the 64-bit variants of JRE & JDK are listed with "64-bit" in parentheses (e.g. "Java SE Development Kit 7 Update 65 (64-Bit)"), while for the 32-bit variants the variant is not mentioned in parentheses (e.g. just "Java SE Development Kit 8 Update 60").
add a comment |
Under Windows 7 in the "Control Panel" under "Programs | Programs and Features" the 64-bit variants of JRE & JDK are listed with "64-bit" in parentheses (e.g. "Java SE Development Kit 7 Update 65 (64-Bit)"), while for the 32-bit variants the variant is not mentioned in parentheses (e.g. just "Java SE Development Kit 8 Update 60").
add a comment |
Under Windows 7 in the "Control Panel" under "Programs | Programs and Features" the 64-bit variants of JRE & JDK are listed with "64-bit" in parentheses (e.g. "Java SE Development Kit 7 Update 65 (64-Bit)"), while for the 32-bit variants the variant is not mentioned in parentheses (e.g. just "Java SE Development Kit 8 Update 60").
Under Windows 7 in the "Control Panel" under "Programs | Programs and Features" the 64-bit variants of JRE & JDK are listed with "64-bit" in parentheses (e.g. "Java SE Development Kit 7 Update 65 (64-Bit)"), while for the 32-bit variants the variant is not mentioned in parentheses (e.g. just "Java SE Development Kit 8 Update 60").
answered Sep 6 '15 at 20:54
user1364368user1364368
92811219
92811219
add a comment |
add a comment |
For Windows, you can check the Java home location. If it contains (x86) it is 32-bit otherwise 64-bit:
public static boolean is32Bit()
{
val javaHome = System.getProperty("java.home");
return javaHome.contains("(x86)");
}
public static boolean is64Bit()
{
return !is32Bit();
}
Example paths:
C:Program Files (x86)Javajdk1.8.0_181binjava.exe # 32-bit
C:Program FilesJavajdk-10.0.2binjava.exe # 64-bit
Why care about a Windows only solution?
If you need to know which bit version you're running on, you're likely fiddling around with native code on Windows so platform-independence is out of the window anyway.
add a comment |
For Windows, you can check the Java home location. If it contains (x86) it is 32-bit otherwise 64-bit:
public static boolean is32Bit()
{
val javaHome = System.getProperty("java.home");
return javaHome.contains("(x86)");
}
public static boolean is64Bit()
{
return !is32Bit();
}
Example paths:
C:Program Files (x86)Javajdk1.8.0_181binjava.exe # 32-bit
C:Program FilesJavajdk-10.0.2binjava.exe # 64-bit
Why care about a Windows only solution?
If you need to know which bit version you're running on, you're likely fiddling around with native code on Windows so platform-independence is out of the window anyway.
add a comment |
For Windows, you can check the Java home location. If it contains (x86) it is 32-bit otherwise 64-bit:
public static boolean is32Bit()
{
val javaHome = System.getProperty("java.home");
return javaHome.contains("(x86)");
}
public static boolean is64Bit()
{
return !is32Bit();
}
Example paths:
C:Program Files (x86)Javajdk1.8.0_181binjava.exe # 32-bit
C:Program FilesJavajdk-10.0.2binjava.exe # 64-bit
Why care about a Windows only solution?
If you need to know which bit version you're running on, you're likely fiddling around with native code on Windows so platform-independence is out of the window anyway.
For Windows, you can check the Java home location. If it contains (x86) it is 32-bit otherwise 64-bit:
public static boolean is32Bit()
{
val javaHome = System.getProperty("java.home");
return javaHome.contains("(x86)");
}
public static boolean is64Bit()
{
return !is32Bit();
}
Example paths:
C:Program Files (x86)Javajdk1.8.0_181binjava.exe # 32-bit
C:Program FilesJavajdk-10.0.2binjava.exe # 64-bit
Why care about a Windows only solution?
If you need to know which bit version you're running on, you're likely fiddling around with native code on Windows so platform-independence is out of the window anyway.
answered Aug 7 '18 at 21:06
BullyWiiPlazaBullyWiiPlaza
6,31844867
6,31844867
add a comment |
add a comment |
If you're using JNA, you can do thisPlatform.is64Bit().
add a comment |
If you're using JNA, you can do thisPlatform.is64Bit().
add a comment |
If you're using JNA, you can do thisPlatform.is64Bit().
If you're using JNA, you can do thisPlatform.is64Bit().
answered Jan 8 at 3:43
鹞之神乐鹞之神乐
1
1
add a comment |
add a comment |
To get the version of JVM currently running the program
System.out.println(Runtime.class.getPackage().getImplementationVersion());
Would that report for the JVM or the operating system? You can run a 32-bit JVM on a 64-bit operating system.
– Thorbjørn Ravn Andersen
Sep 24 '17 at 7:18
That doesn’t use JMX?
– Thorbjørn Ravn Andersen
Sep 24 '17 at 11:52
1
This returns something like1.8.0_172ornullonJava 10and doesn't answer the question anyway.
– BullyWiiPlaza
Aug 7 '18 at 21:08
add a comment |
To get the version of JVM currently running the program
System.out.println(Runtime.class.getPackage().getImplementationVersion());
Would that report for the JVM or the operating system? You can run a 32-bit JVM on a 64-bit operating system.
– Thorbjørn Ravn Andersen
Sep 24 '17 at 7:18
That doesn’t use JMX?
– Thorbjørn Ravn Andersen
Sep 24 '17 at 11:52
1
This returns something like1.8.0_172ornullonJava 10and doesn't answer the question anyway.
– BullyWiiPlaza
Aug 7 '18 at 21:08
add a comment |
To get the version of JVM currently running the program
System.out.println(Runtime.class.getPackage().getImplementationVersion());
To get the version of JVM currently running the program
System.out.println(Runtime.class.getPackage().getImplementationVersion());
edited Sep 24 '17 at 12:32
answered Sep 12 '17 at 18:54
Olu SmithOlu Smith
1,4731822
1,4731822
Would that report for the JVM or the operating system? You can run a 32-bit JVM on a 64-bit operating system.
– Thorbjørn Ravn Andersen
Sep 24 '17 at 7:18
That doesn’t use JMX?
– Thorbjørn Ravn Andersen
Sep 24 '17 at 11:52
1
This returns something like1.8.0_172ornullonJava 10and doesn't answer the question anyway.
– BullyWiiPlaza
Aug 7 '18 at 21:08
add a comment |
Would that report for the JVM or the operating system? You can run a 32-bit JVM on a 64-bit operating system.
– Thorbjørn Ravn Andersen
Sep 24 '17 at 7:18
That doesn’t use JMX?
– Thorbjørn Ravn Andersen
Sep 24 '17 at 11:52
1
This returns something like1.8.0_172ornullonJava 10and doesn't answer the question anyway.
– BullyWiiPlaza
Aug 7 '18 at 21:08
Would that report for the JVM or the operating system? You can run a 32-bit JVM on a 64-bit operating system.
– Thorbjørn Ravn Andersen
Sep 24 '17 at 7:18
Would that report for the JVM or the operating system? You can run a 32-bit JVM on a 64-bit operating system.
– Thorbjørn Ravn Andersen
Sep 24 '17 at 7:18
That doesn’t use JMX?
– Thorbjørn Ravn Andersen
Sep 24 '17 at 11:52
That doesn’t use JMX?
– Thorbjørn Ravn Andersen
Sep 24 '17 at 11:52
1
1
This returns something like
1.8.0_172 or null on Java 10 and doesn't answer the question anyway.– BullyWiiPlaza
Aug 7 '18 at 21:08
This returns something like
1.8.0_172 or null on Java 10 and doesn't answer the question anyway.– BullyWiiPlaza
Aug 7 '18 at 21:08
add a comment |
protected by Community♦ Mar 23 at 7:47
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
3
Just out of curiosity, why would you need to know the natural size of the system? Details such as this are abstracted away in Java, so you shouldn't (in theory, at least) have to know them.
– Patrick Niedzielski
Jan 14 '10 at 4:29
3
It lets me roughly estimate the memory requirements for objects due to pointers. Curiosity too -- seemed like there should be a way, but I'd never heard of it.
– BobMcGee
Jan 14 '10 at 18:33
81
This "detail" is not abstracted away when interacting with the Java Native Interface. 32-bit DLLs can't be loaded with a 64-bit JVM (and vice versa). So this is quite essential information for anyone using JNI. It's a pity that there seems to be no portable way to obtain this info. One way is to first try loading a 32-bit version of the DLL, and if it fails, try the 64-bit version, etc. Ugly!
– Joonas Pulakka
Apr 30 '10 at 7:17
11
Another situation where discerning between 32 or 64 bit JVMs is important is for mapped files. On 32 bit systems only 2GB can be mapped, so it's important to map and unmap file segments accordingly so that this limit is not exceeded, while on 64 bit jvms the limit is much, much, much higher.
– Simone Gianni
Sep 9 '12 at 21:07
2
It's really nice to be able to choose the numerical algorithm that will be fastest on the machine in question.
– dfeuer
Apr 22 '14 at 18:09