Determine JRE architecture 32-bit vs 64-bit [duplicate] - java

This question already has answers here:
How can I tell if I'm running in 64-bit JVM or 32-bit JVM (from within a program)?
(13 answers)
Closed 6 years ago.
The thing I'm trying to find out is if my JRE is for 32-bit or 64-bit.
And yes, I have tried java -version / -showversion / -fullversion but it doesn't say anything useful (at least not to me).
This is what I get when I do java -version:
java version "1.6.0_11"
Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
Java HotSpot(TM) Client VM (build 11.0-b16, mixed mode)
So all I have access to is a zipped JRE's bin-folder, a different JRE is installed and setup, that's not the one I'm trying to check the version of.
Any ideas?

System.getProperty("sun.arch.data.model");

If you're trying to do it from the command line, file is your friend:
$ cat `which java` | file -
/dev/stdin: ELF 64-bit LSB executable, x86-64, version 1 (SYSV),
dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for
GNU/Linux 2.6.32, BuildID[sha1]=440c433f29884a88f874e6d8260f156f4b352818,
stripped
(Using cat because in my case java is a symlink.)

I get the following when I run the command on my 64-bit machine. The java -version always gets you the on which is set in Environment properties or whatever is chosen from Java icon in JRE. There may be others as well installed on your machine. Look up on "arch".
C:\Users\nyera>java -version
java version "1.6.0_27"
Java(TM) SE Runtime Environment (build 1.6.0_27-b07)
Java HotSpot(TM) 64-Bit Server VM (build 20.2-b06, mixed mode)

Related

What version of Java is "1.8.0_191" on my Ubuntu install?

On of our (remote) developers needs to install FDT (an Eclipse based IDE) to compile some legacy ActionScript code. I've got FDT working on my Ubuntu 18.04 laptop just fine, but the dev is having trouble getting it to work on his Mac. When he has Java version 7, 8 or 9 installed he gets a message saying
we need legacy java you can download it here...
and if he uses Java version 6, it says it needs version 7 or more.
So I checked which version I have on my Ubuntu 18.04 laptop so he can get the same one, and to my surprise it says:
$ java -version
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
As far as I know Java is WAY ahead of version 1.8. So I logged into our production server (Ubuntu 16.04) and there we've got something similar:
$ java -version
openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-8u191-b12-0ubuntu0.16.04.1-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)
I checked out the OpenJDK website and there it says OpenJDK is now at version 11.
What version of Java my laptop is actually running so our dev can get the same version?
You are using Java 8.
The Mac problem is a historic one because the legacy question is for a 32-bit JVM for some programs and you need a 64-bit for Java 8.
Install the Java 6 the programs want and then install A newer java from oracle and he should be good to go.

Check the if version of JDK installed on macOS is the correct one

I have a macbook with latest HighSierra installed and from System Preferences / Java Panel. It says that i have got latest Java version installed: java 8 update 181.
From the "Java" tab of the aforementioned "Java settings" dialog i can see that the version 181 it is referring to is installed in /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java
If i try to execute that binary (i.e. java -version) i actually get:
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build
1.8.0_181-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
however when i try to launch "java" from a generic prompt or if i try to execute javac i get a different result:
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)
this latter java is installed in /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/
So it seems to me that i have got a jre (181) and a jdk (40) is this correct?
if so, is this the correct setup on mac? i started to wonder when forticlient analyzer showed up a bunch of CVE security issues related to JDK that are fixed in update 181.

why java version not updated on mac machine?

I checked my java version from terminal .I got this information
Last login: Sun Mar 15 08:46:08 on ttys000
localhost:~ naveenkumar$ java -version
java version "1.7.0_10"
Java(TM) SE Runtime Environment (build 1.7.0_10-b18)
Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)
localhost:~ naveenkumar$
I install new java 1.8 JRE .close my terminal .Agan i type java -version .I found the same version .
why ? how to upgrade java version.
You installed Java 8 but it didn't overwrite this: /usr/bin/java
The easiest way for you to solve this problem is to install Java 8 JDK, not JRE. After install JDK, your path should be automatically updated.

No Java runtime present, requesting install

I have java JDK installed sucessfully in my mac os 10.9 ..
$ java -version
java version "1.8.0_20"
Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)
But when i try to run eclipse it asks me to jave SE 6 Runtime again !!!
It looks like eclipse is unable to locate the installed java. You can tell eclipse to point to this version of java by modifying eclipse.ini file
In eclipse.ini file, we need to add -vm option to point to the java8 location:
See: http://wiki.eclipse.org/Eclipse.ini#-vm_value:_Mac_OS_X_Example

R looking for the wrong java version

I installed/uninstalled java jre/jdk now many times and finally installed the older version 1.6.0_17 which is now located at "C:\Program Files\Java\jre6\bin". Now after all if I call 'java -version' within R i can see that R is looking for Java at the old path which is now wrong. The question is: Why is R looking for Java at the wrong path even so the windows path is set correctly? There are no double entrys within the windows path as far as I can see and I restarted R as well as Windows more then once since then. Any Ideas where R takes the wrong path from?
On windows shell:
> set
[..]
OS=Windows_NT
Path=C:\Program Files\Java\jre6\bin;
[..]
> java -version
java version "1.6.0_17"
Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
Java HotSpot(TM) 64-Bit Server VM (build 14.3-b01, mixed mode)
within R:
> system("java -version")
Error: could not open `C:\Program Files (x86)\Java\jre6\lib\i386\jvm.cfg'
You problem depends on 64/32 bit versions.
You run 32-bit R, which use 32-bit command prompt and find 32-bit java. If you use 64-bit R then it runs 64-bit command promt and proper java.
You could check it by run 32-bit command promt (following this post):
Click Start.
Type %windir%\SysWoW64\cmd.exe in Start Search box.
Press Enter.
Type java -version
In my system it fails because I don't have 32-bit java. With standard cmd.exe I get proper path.
For possible solution there are two ways. Install 32-bit R and 32-bit Java or 64-bit R (which is officially supported from 2.11 version) and 64-bit Java. On my system (64-bit Windows 7) I've got both sets, so on 32-bit combination I get:
> system("java -version")
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode, sharing)
And on 64-bit:
> system("java -version")
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)
On 64-bit version you could call 32-bit Java using 32-bit cmd:
shell(
"java -version",
shell = file.path(Sys.getenv("windir"),"SysWoW64/cmd.exe")
)
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode, sharing)
About Shane's comment I think the question is how R get path to 32-bit cmd. Because I can't find a way to call 64-bit cmd on 32-bit R.
You're assuming that R is looking at the windows path, but the code is telling you that it's not. So check your assumption: R is getting the path somewhere else.
If I open up a command shell on my Windows machine and type "java -version" I get this:
C:\>java -version
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode, sharing)
If I check the PATH on my machine, I get (edited for clarity):
C:\>set path
Path=;C:\JDKs\jdk1.6.0_13\bin;
If I open up R version 2.8.1 and run system("java -version") I get this:
> system("java -version")
java version "1.6.0_15"
Java(TM) SE Runtime Environment (build 1.6.0_15-b03)
Java HotSpot(TM) Client VM (build 14.1-b02, mixed mode, sharing)
>
So, like I said, R is not using my path to find java.exe. It's using something else.
I got to this page trying to work out why my JDK was reporting 64 bit despite the PATH and JAVA_HOME were pointing to 32 bit.
I dont even know what R is, but this article might help (it solved it for me)
http://www.tipandtrick.net/2008/how-to-open-and-run-32-bit-command-prompt-in-64-bit-x64-windows/
In a nutshell, dont run from 'cmd' use '%windir%\SysWoW64\cmd.exe' instead.
Or, put your JDK at the front of the path instead of the end (I dont think this is ideal).
You may also need to check the registry, R may have its own setting. You can also start regedit and do a search on the path to binary that it is starting.
There is a simple way to check which version of Java you have installed on your computer using the rJava package.
rJava::.jinit()
rJava::.jcall("java.lang.System", "S", "getProperty", "java.version")

Categories