Enabling both 32 and 64 bit Java Runtime Environment - java

I recently installed both 32 and 64 bit JRE in my machine, but when I try to check using command prompt, it only detects the 64bit JRE.
java -d64 -version ->using this command outputs the version and all
java -d32 -version ->using this command just tells me that "this instance does not support 32-bit JVM"
More over, I tried to configure Java through the control panel (java control panel > java > view > user > add 32 bit JRE > Okay > Apply). I tried adding the 32 bit JRE, but after I press apply, then close the Java control panel window and reopen it, the 32bit JRE is no longer there.
Can someone tell me what I'm missing here?
Additional details: I'm using 64 bit windows 7.

AFAIK The -d64 and -d32 only ever worked on Sparc Solaris.
If you have 64-bit JVM it will run all your programs unless they use a 32-bit shared library, in which case I suggest either a) don't do that or b) use the 32-bit JVM only when you need to by specifying the path.

Related

Java bluetooth bluecove application

I'm working on a bluetooth java application under eclipse in OS X 10.10.1 Yosemite 64bit with the blue cove-2.1.0 jar. When I run the application I get the error message:
Native Library bluecove not available
Through a web search I found that the issue is caused by the 64 bit version of Java, but when I try to run the application with the -d32 argument passed to the VM I get the error:
Error: This Java instance does not support a 32-bit JVM.
Please install the desired version.
Is there anyway to run this application despite the 64 bit configuration? or is there any other library despite bluecove that can manage a 64 bit environment?
A similar thing happened to me with a different java application (jruby), around which I was able to work by resetting my JAVA_HOME to a JVM that supports 32-bit mode. Essentially your 64-bit JVM is trying to tell you that it won't run in 32-bit mode, even when you specify the -d32 option.
To work around this, try running: /usr/libexec/java_home -d32
On my 64-bit Yosemite machine, that command returned /Library/Java/JavaVirtualMachines/1.6.0_65-b14-462.jdk/Contents/Home, which is the path to a JVM on my machine that will run in 32-bit mode. If you have one or more 32-bit-capable JVMs on your machine, you'll get a path to one of them, which you can then use to set your JAVA_HOME variable accordingly and you'll be off to the races.
If you don't have a 32-bit-capabile JVM on your machine, you will need to install one via the Oracle web site or homebrew and then set your JAVA_HOME accordingly.
If you want to skip a step or two, just do this -- export JAVA_HOME=`/usr/libexec/java_home -d32` -- which will automatically set your JAVA_HOME to the first detected instance of a JVM capable of running in 32-bit mode.

why I get this error while starting eclipse

I have 64 bit window 7 ,
I have installed java 6 and java 7 (jdk and jre) in program files(86)
and jre 7 in program files.
I cannot open eclipse, what would I do to start it?
In 64 bit Windows -
program files(86) -> contains the 32 bit programs installed into your
system.
program files -> contains the 64 bit programs or default installed into
your system
What you need is 64 bit jdk, download it from here - Link
exe - jdk-7u60-windows-x64.exe
^^^^^
Looks like you're using 64bit version of Java and a 32 bit version of Eclipse. It's trying to find a 32bit Java version (or vice versa) and that's why it tells you that you need at least Java 1.5.. Try switching to a 64bit Eclipse and also check if your environment variables are set properly, especially %JAVA_HOME%.. You can do a quick check if you're using the correct Java version by running the command
java -version
from the command line.

Running java in 32 bit mode on windows 64

I need to run java in 32 bit mode under windows 8.1 64 bit.
I have installed java 7 jre under c:\Program Files\Java\jre7 (64bit JVM) and under c:\Program Files (x86)\Java\jre7 (32bit JVM).
However, if from cmd I issue java -d32 -version, I get this error:
Error: This Java instance does not support a 32-bit JVM.
Please install the desired version.
Without the -d32 switch it confirms its running the 64 bit JVM:
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
So I opened the java control panel and added the 32bit JVM to the user installed JRE (system tab does not allow me to change anything even if running as administrator), but nothing changes.
I've read some posts of users saying that with java 7+ the -d32 mode should be supported but I can't get it.
Note: Please note that I cannot remove the 64bit JVM because I need it for other applications
According to this FAQ :
How do I select between 32 and 64-bit operation? What's the default?
The options -d32 and -d64 have been added to the Java launcher to
specify whether the program is to be run in a 32 or 64-bit
environment. On Solaris these correspond to the ILP32 and LP64 data
models, respectively. Since Solaris has both a 32 and 64-bit J2SE
implementation contained within the same installation of Java, you can
specify either version. If neither -d32 nor -d64 is specified, the
default is to run in a 32-bit environment. Other Java commands
(javac, javadoc, etc.) will rarely need to be executed in a 64-bit
environment. However, the -d32/-d64 options may be passed to these
commands and then on to the Java launcher using the established -J
prefix option (eg: -J-d64).
All other platforms (Windows and Linux) contain separate 32 and 64-bit installation packages. If both packages are installed on a
system, you select one or the other by adding the appropriate "bin"
directory to your path. For consistency, the Java implementations on
Linux accept the -d64 option.
I've found another solution to that.
By using launchj4 I can wrap my jar into an exe and I can specify the JRE I want to use and force it to search for a 32bit JVM, set min and max version etc (see the JRE).
The wrapper will automatically search installed JRE's and chose the one that meets the requirements.
Also wrapping my jar into an exe is more convenient for deploying my application.
You can have both 32bit and 64 bit installed on the same machine. Infact you can have multiple version of each of 32bit and 64bit installed (eg - java6 and java7). Because each JRE will be installed in different folders, it usually does not matter.
When running different versions of jre, your application will search for the Java executable using the PATH variable. So if Java 32bit is first on the PATH, you will have problems running a Java 64bit application. You can modify the path to use a certain Java version e.g. by defining a environment variable JAVA32HOME with the value C:\java\java6 (32bit) and change the command to
%JAVA32HOME%\bin\java ...
Or you can manually add the version you want to use, first in the PATH variable. Remember the first instance of java.exe found while searching your PATH will be the one that is executed.
Why don't you just install the 32-bit version of Java as well from the link below:
Java Downloads for All Operating Systems
Consider going to your settings , choosing your active profile then click on advanced settings , now on the menu that pops up and choose the version you would like to work with . Once everything is configured use the terminal to verify the usage of the right version. Now incaqse thus pdate-alternatives --config java. through the terminal and update any values by selecting the version you like and pressing down on the enter key on the output you get

Compile 32 bit Java builds on 64 bit machine with Eclipse

so the questions as in the title, I need to run my server application in Tomcat on a System which is 32 bit Windows XP, I am working and compiling on my 64 bit Windows 7 in Eclipse. How do I compile it to 32 bit, what do I need to do? I assume it won't work on the 32 bit Windows when I'm compiling it on a 64 bit machine?
Java doesn't build 32-bit or 64-bit applications - bytecode is portable across different bit architectures.
The only exception is native libraries that you might be using in your code. If there are any then you will have to manually compile those for the respective platform. Otherwise the java code is totally portable across 32-bit and 64-bit platforms.
The problem is your JNI DLL, which needs to be compiled for 32-bit to match the 32-bit JRE.
Java is independent of the OS.
You can compile with your 64bit machine and run this on a 32bit computer as long as this computer has a 32bit VM.
If you're still searching for some "simple" solution, one would be to install a 32 bit os in a virtual machine and run eclipse from there.. Very ugly I know, but it works.
Another approach is mentioned here. How to launch java swing app which used precompled DLL from cmd?
You could install a 32bits jdk on a 64bits machine. point the JAVA_HOME to this jdk and use it. It

Will a 64 bit JVM run in 64 bit mode when no option like -d32 or -d64 is specified

I have installed a 64 bit Java on a 64 bit Centos machine. My query is that if I dont specify the -d64 option will the JVM run in 32 bit mode even if there is no 32 bit JVM installed ?
Also I was a bit curious if we can use the -d64 option with "javac". If yes, then what does it imply or where could it be used? I came across this when reading this article.
Thanks
The selection of the data model (bits) for the JRE is to constrain the operation of the application to only run in one mode. The java byte code is designed to work in both data models, so for the 100% pure java applications, will work according the behavior and benefits of each architecture.
But, if your application use native libs that work only in one mode, then the application will fail under the not supported one. For that, you must explicitly indicate in which mode it should run.
When you set -d32 or -d64 the JRE will not start your application if it can't run in the selected mode.
From the Oracle document you linked to:
How do I select between 32 and 64-bit operation? What's the default?
The options -d32 and -d64 have been added to the Java launcher to specify whether the program is to be run in a 32 or 64-bit environment. On Solaris these correspond to the ILP32 and LP64 data models, respectively. Since Solaris has both a 32 and 64-bit J2SE implementation contained within the same installation of Java, you can specify either version. If neither -d32 nor -d64 is specified, the default is to run in a 32-bit environment.
Other Java commands (javac, javadoc, etc.) will rarely need to be executed in a 64-bit environment. However, the -d32/-d64 options may be passed to these commands and then on to the Java launcher using the established -J prefix option (eg: -J-d64).
All other platforms (Windows and Linux) contain separate 32 and 64-bit installation packages. If both packages are installed on a system, you select one or the other by adding the appropriate "bin" directory to your path. For consistency, the Java implementations on Linux accept the -d64 option.
(emphasis mine)
So, according to the document you linked to, the default is to run in a 32-bit JRE, and it is possible to run javac in a 64-bit JRE by passing -J-d64 rather than simply -d64.
However, note that this document also says that it applies to Java 1.4, and says nothing about more recent versions of Java.

Categories

Resources