Перейти к содержимому

Как узнать какая java установлена 32 или 64

  • автор:

How to find if JVM is 32 or 64 bit from Java program? Example

Check if JVM is 32 or 64 bit from the Java program:

How to check if JVM is 32 or 64 bit in host

As I said earlier there are two different approaches either using Java system property like » sun.arch.data.model » or » os.arch » or by running java command from the script and checking its output for certain characters to identify whether JVM is 64 bit or not. let’s see an example of different ways to find if JVM is 32 bit or 64 bit:

1. By using System property sun.arch.data.model :

2. By using System.getProperty(« os.arch «)

3. java -d64 -version

4. java -version

9 comments :

I wanted know whether my JVM is 64 bit or not and found your tips very relevant. I don't require check if JVM is 32 bit but if any JVM is 64 bit than we do load native .so file from separate location.

Calling System.getProperty("os.arch") on a 64-bit Linux system (OpenSUSE 11.4) with a 32-bit JVM returns: i386

I used Java(TM) SE Runtime Environment (build 1.6.0_22-b04)

Hi, We have several JDK and JRE installed on Solaris Sparc box, I want to find out which installed JDK or JRE is 64 bit ? Can you please share command to do that ? Also is it possible to run 32 bit JVM in 64 bit machine i.e. if My Solaris sparc box is 64 bit but JVM is 32 bit can I execute Java program there ?

One of the interesting point to know relate to 32 bit or 64 bit installation is that it varies on different environment e.g In windows and Linux you have separate installation for 32 bit and 64 bit JVM but on Solaris machine e.g. Sparc, one JVM installation represent both 32 bit and 64 bit JVM and until specified by -d32 and -d64, they by default run on 32 bit data model. Which means you may not able to assign more than 3.5GB of heap, despite running 64 bit JVM in 64 bit machine. Solution is use -d64 JVM option to run JVM on 64 bit data model.

How do i solve this error:
Could not create the java virtual machine
A fatal exception occurred. program will exit

I got "JVM Bit size: x86" for os.arch and "32bit" for sun.arch.data.model on my intel machine with 64 bit windows 7 os.

Just change the JRE to JDK 1.7.0_17, you will get the 64 bit JVM.

A nice tutorial on
JVM Architecture Specification Basic The Heap Area Introduction, teach about the JVM Heap Area in details
http://www.youtube.com/watch?v=c-A7ZzxjWUI

JVM Architecture Specification Basic The Method Area explained, teach about the JVM method area
http://www.youtube.com/watch?v=a5GzF2fSSCE

As this question is already answered and explained by Java geeks , I just want to add little extra in it — generally people prefer to switch over 64 but JVM when the existing heap space (1.5 to 1.8 M varies OS to OS) size provided by 32 bit JVM is not suffice for their application , but these days it is very common that people are migrating to 64 bit without understanding the requirement of applications.

Как узнать какая Java установлена 32 или 64?

Вы можете запустить C:\ProgramData\Oracle\Java\javapath\java.exe -version . Среди распечатанных деталей вы должны увидеть, является ли это 32- или 64-битной версией.

Как скачать и установить Java на Windows 10?

Загрузка и установкаПерейдите на страницу скачивания вручнуюНажмите кнопку Windows Online (Windows Установка из сети)Откроется диалоговое окно 'File Download' (Загрузка файла), где предлагается выполнить или сохранить загружаемый файл. Чтобы запустить программу установки, нажмите кнопку Run (Запустить).

В чем разница между JDK и JRE?

JRE – Java Runtime Environment, Java-окружение времени выполнения. . JDK – Java Development Kit, набор Java-разработчика. Это полнофункциональный SDK для Java. JDK включает в себя JRE, но кроме того содержит компилятор ( javac ) и другие инструменты разработки, такие как javadoc и jdb .

Нужно ли устанавливать JRE?

JRE разумеется тоже входит в дистрибутив JDK. Правило очень простое: если вы собираетесь что-нибудь писать на языке программирования Java, значит вам потребуется JDK. А если только запускать готовые программы — тогда достаточно JRE.20 нояб. 2014 г.

Какая сейчас версия Джавы?

По состоянию на сентябрь 2019 года Java 13 является последней выпущенной версией Java, с новыми версиями, выходящими каждые 6 месяцев — Java 14 запланирована на март 2020 года, Java 15 на сентябрь 2020 года и т. д. В прошлом циклы выпуска Java были намного длиннее, до 3-5 лет!17 февр. 2020 г.

Почему Java безопасный язык?

Причина: 1. Поскольку программа java запускается внутри собственной виртуальной машины 2. Скрытие данных в Java (OOPs) делает его одним из безопасных языков. Возможно, некоторые моменты есть, но не могут вспомнить его прямо сейчас.

Java Program to Check if JVM is 32 or 64 bit

JVM Stands for Java Virtual Machine. It is an abstract computing machine that allows a computer to run a Java program. It is a platform-independent environment, responsible for compiling Java programs by performing conversion of Java code into machine language i.e. byte code. The memory needed by JVM to run a Java program is called heap memory.

In Java, the getProperty() method is used to get information about various properties related to the system. Similarly, there two different approaches to check the bit of JVM by using System property “sun.arch.data.model” or “os. arch”. It will return either 32 bit or 64 bit based on your Java installation.

Method required : get.Property()

String System.getProperty( String key )

Parameter:

Key is the property of the operating system

Return Type

1) Returns a string containing the value of the property

2) Returns Null if the property does not exist

There are basically 3 methods to check whether the JVM is 32 bit or 64 bit:-

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?

13 Answers 13

For certain versions of Java, you can check the bitness of the JVM from the command line with the flags -d32 and -d64 .

To check for a 64-bit JVM, run:

If it’s not a 64-bit JVM, you’ll get this:

Similarly, to check for a 32-bit JVM, run:

If it’s not a 32-bit JVM, you’ll get this:

These flags were added in Java 7, deprecated in Java 9, removed in Java 10, and no longer available on modern versions of Java.

You retrieve the system property that marks the bitness of this JVM with:

Possible results are:

  • "32" – 32-bit JVM
  • "64" – 64-bit JVM
  • "unknown" – Unknown JVM

As described in the 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 property sun.arch.data.model has the value "32", "64", or "unknown".

An example where this could be necessary is if your Java code depends on native libraries, and you need to determine whether to load the 32- or 64-bit version of the libraries on startup.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *