Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run 32-bit Java on Mac OSX 10.7 Lion

Tags:

From my experience with Windows 7 (64-bit) and Java, a 32-bit JRE uses less memory and runs significantly faster than a 64-bit JRE (provided you don't need or benefit from having a lot of memory). I imagine the same thing is true for Mac OSX (and other platforms) as well.

I am currently running OSX Lion (v10.7), and I have installed the standard Java app. Under Java Preferences, I see "Java SE 6" from "Apple Inc." for both CPU-types "32-bit" and "64-bit" version "1.6.0_26-b03-383". I have changed the preferred order to put the 32-bit version on top of the 64-bit version, hoping that this would make the 32-bit version default.

But "java -version" still says:

java version "1.6.0_26" Java(TM) SE Runtime Environment (build 1.6.0_26-b03-383-11A511c) Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02-383, mixed mode) 

Is it possible to use the 32-bit version by default? And how?

Also, does anyone have experiences / comparative measurements regarding speed and memory efficiency between the 32/64-bit versions?

like image 842
Ulrik Avatar asked Aug 04 '11 13:08

Ulrik


People also ask

Is JDK available for 32-bit?

This procedure installs the Java Development Kit (JDK) for 32-bit Linux, using a self-extracting binary file. The JDK download includes the Java SE Runtime Environment (JRE) – you do not have to download the JRE separately.

Why does my Mac say unable to locate a Java Runtime?

The message “Unable to load Java Runtime Environment” means that the Mac computer cannot load JRE, either because it is out of date or (more usually) because it has not yet been downloaded and installed. It can also happen after the computer OS X has been updated, e.g. to 10.14 Mojave from 10.13 Maverick.

Why Java is not showing in System Preferences Mac?

If the Java icon is not present (under the Other category) in System Preferences, you do not have an Oracle JRE installed. Q: I have Oracle's version the JRE installed, but it is not listed in Java Preferences. A: This is correct. The JRE will not show up in the Java Preferences list unless you install the full JDK.


2 Answers

I found out now, that the 32-bit JVM can be explicitly launched using the -d32 switch.

On my machine, "java -version -d32" says:

java version "1.6.0_26" Java(TM) SE Runtime Environment (build 1.6.0_26-b03-383-11A511c) Java HotSpot(TM) Client VM (build 20.1-b02-383, mixed mode) 

and although it doesn't say so, it is a 32-bit JVM.

like image 143
Ulrik Avatar answered Oct 09 '22 17:10

Ulrik


The latest versions of Java 64-bit have -XX:+UseCompressedOops on by default (if your heap is less than 32 GB). This means 32-bit references are used in any case. The objects are still slightly bigger (4 bytes more overhead)

This article compares 32-bit, 64-bit with UseCompressedOops Java: How much memory do different arrays and collections consume

In terms of performance, I have found it to be 5-10% depending on what you are doing. If you are using a lot of long values it will be faster to use 64-bit.

like image 44
Peter Lawrey Avatar answered Oct 09 '22 19:10

Peter Lawrey