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?
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.
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.
Go into the "Java Preferences" App and drag java 32 bit to the top of the list.
Try the below steps:
Open terminal and go to /System/Library/Frameworks/JavaVM.framework/Versions/
Type ls -l to list all available Java versions
Enter sudo ln -fhsv CurrentJDK
Reference: Changing Java Version
in /System/Library/Frameworks/JavaVM.framework/Versions
I found version 1.6 installed and changed the path for java,javac to point to
/System/Library/Frameworks/JavaVM.framework/Versions/1.6/home using environment
alias rather than the default link found in /usr/bin/
Related
I'm using Processing 1.5.1 for Mac OS X El Capitan and when I run some code on my app it displays that message. When I type java -version I get:
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-468-11M4833)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-468, mixed mode)
and when I type /usr/libexec/java_home -V I get:
Matching Java Virtual Machines (3):
1.8.0_65, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home
1.6.0_65-b14-468, x86_64: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
1.6.0_65-b14-468, i386: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home
I've tried setting JAVA_HOME to:
export JAVA_HOME=`/usr/libexec/java_home -v 1.6.0_65-b14-468`
but still when I reopen Processing it still displays the same error. Any help or suggestions to force it to run JVM 32-bit?
Processing 1.5 is pretty old. I wouldn't use it unless you have a very specific reason to do so. And even then, you should probably try to find a workaround.
Instead, you should try to use the latest version of Processing (right now, version 3.1.1) if at all possible. But you're using a library that hasn't upgraded yet, so you have to rely on 2.2.1.
Version 2.2.1 added a bunch of stuff over Processing 1.5, including:
Better 32 and 64-bit support. We now support separate 32- and 64-bit libraries and have added separate 32- and 64-bit versions of the Processing download. On Mac OS X, you can even select which mode you'd like to use.
I don't know if this is exactly what fixed your problem, but I would bet that Processing 2.2.1 added something that fixed the issue.
As soon as your library upgrades to Processing 3, you should upgrade your Processing version.
Selecting JVMs on a mac is a pain. I use Jenv. You could try using jenv to select a specific Java version.
brew install jenv
or have a look here:
http://www.jenv.be/
You need to register your JVMs to set it up but you can then set a default JVM and also a default local JVM for a particular directory. Very handy.
You might need to run the following correctly set JAVA_HOME:
jenv exec [your app]
Good luck.
Recently reinstalled system and meet interesting problem. I installed java jdk8, however when I try to verify version on java.com it asks to install java. Meanwhile:
java - version
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)
echo %JAVA_HOME%
E:\Programms\Java\JDK8
echo %JRE_HOME%
E:\Programms\Java\JDK8\jre
echo %PATH%
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Wi
ndows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;E:\Pr
ogramms\Java\JDK8\bin;E:\Programms\Java\JDK8\jre\bin;
Java Control Panel > Security > Enable Java content in Browser is checked
Why browser and java.com does not recognize my java instalation? Java plug-in is not included in jdk?
I suspect that you need to install the JRE rather than a JDK using the Windows installer at (java.oracle.com).
This should set up everything properly.
Posting comments as an answer as per request by Yarh:
Probably the browser is 32 bits, then indeed there are not going to be any Java plugins installed in it if you installed the 64 bits Java runtime as part of the JDK. I always install the 64 bits JDK and then separately I install the 32 bits runtime through java.com (minding not to install the flipping toolbar).
There is no conflict to install both a 32 bits runtime and a 64 bits runtime, that is the advised way to support all types of browsers.
I have a 64 bit linux os:
$ uname -p
x86_64
java -version listed:
java version "1.6.0_43"
Java(TM) SE Runtime Environment (build 1.6.0_43-b01)
Java HotSpot(TM) Server VM (build 20.14-b01, mixed mode)
I am trying to run a 64 bit jvm with 4096 min heap size ( Its a heavy weight app ). When i add -d64 option i get the message
Running a 64-bit JVM is not supported on this platform
With out -d4 option and with heap size 2048 it works fine. But the memory isnt enough so i need to use 64 bit JVM with 4Gigs. Can anyone tell me why its not accepting d64 ?
Thanks #Adi Dembark and #nos found the issue. It was indeed a 32 bit jvm. changing to 64 bit fixed it.
In my BAT file I would like to have something like:
set javaVersion=...
if %javaVersion% equ 32 (
echo "do 32 Java routine"
) else (
echo "do non-32 Java routine"
)
On a 64bit machine, with JRE 64bit installed, in the registry under HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment and HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.6 I see almost the same values as on a 32bit machine with JRE 32bit installed:
HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment
CurrentVersion: 1.6
Java6FamilyVersion: 1.6.0_26
HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.6
JavaHome: C:\Program Files\Java\jre6
MicroVersion: 0
RuntimeLib: C:\Program Files\Java\jre6\bin\client\jvm.dll
Therefore, I could check if it is 64bit Java by checking if PROGRAMFILES(X86) is defined and if JavaHome points to location which starts with C:\Program Files\.
But is there a better option?
Actually, the 32-Bit Server does not output "32-Bit". On my system (32-bit Kubuntu), I get the following java -versionoutput:
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) Server VM (build 20.1-b02, mixed mode)
Therefore, it's a better idea to just test for absence of 64-Bit, instead of presence of either.
You could capture the output of java -version - it's in there.
Here's the output on my mac:
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03-384-10M3425)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02-384, mixed mode)
You should find either "64-Bit" or "32-Bit" in the output.
If you just need to know if there is Java available then run a small class doing something with the default java command.
If you need to know which libraries to use, then instead of poking around the registry then run a small class which tries to call native code in your libraries and let the bat file know if it went well, and run it once for each of your supported platforms.
If none works, then report that. If one or more works then choose the one you like best and use that.
In other words: Explicitly test for what you need to know. Any assumptions will eventually fail.
The simplest way to do this is to parse the exit code of java -d64 -version.
For 64-bit JDK, it would be 0, for 32-bit: 1.
So, you may introduce new variable java64bit:
java -d64 -version >NUL 2>NUL
set java64bit=%ERRORLEVEL%
How do I tell if I am using 64-bit Eclipse and 64-bit JVM on my Linux machine?
To verify that you are using 64-bit JVM:
java -d64 -version
In a comment above you say that you're using a software package that requires "such constraints". I'm not exactly sure what you mean by that, but for Java programs, it doesn't matter if the underlying Java implementation is 32-bit or 64-bit (well, as long as it doesn't need a huge amount of memory, for example). A normal Java program should run the same, no matter if it runs on a 32-bit or 64-bit OS.
java -version should give you an indication if your Java runtime environment is 32-bit or 64-bit.
Eclipse contains some native binaries (for the SWT libraries). Depending on if your Java runtime environment is 32-bit or 64-bit, you need a version of Eclipse with the corresponding native binaries. The Eclipse download page contains links for 32-bit and 64-bit Linux versions of Eclipse.
Note: If your OS is 64-bit but your Java RE is 32-bit, you will still need the 32-bit Eclipse.
Usually you can tell from your eclipse.sh or your eclipse.ini if you are using 32bit or 64bit version, as the involved plugins are quite different.
As for the JVM, are you running Eclipse with something other than your default JVM? 'which java' usually tells you what you're using as your java executable.