On RHEL 6 64 bit, first I installed openJDK via yum and later I could validate the same by running rpm -qa | grep jdk
Later, I removed the openjdk and downloaded the Oracle jdk. Oracle gave me a .bin file which is a slef extraclter and installed java.
QUESTION: Now, how do I verify by looking at the installed java that this is coming from the oracle JDK and not the openJDK.
BTW, oracle provides a rpm for their JDK, but I chose to install it using .bin file.
Moderators, please move my question to superuser if you feel so. I chose to post on stack overflow as we have numerous Java programmers here who would easily know the answer.
EDIT:
Sorry, I already had run those commands but is does not say anything specific to Oracle:
# java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)
# javac -version
javac 1.6.0_45
# which java
/usr/bin/java
# whereis java
java: /usr/bin/java /etc/java /usr/lib/java /usr/share/java
# echo $JAVA_HOME
/usr/lib/jvm/java
First use which javac to see which binary is beeing used.
Then simply run javac -version to see which version you are running.
If the output mentions
Java HotSpot(TM)
Then it is most likely Oracle Java SDK.
Related
My os is Ubuntu 16.04 LTS.
$ cat /etc/profile # part content of this file
JAVA_HOME=/usr/local/java/jdk1.8.0_101
JRE_HOME=$JAVA_HOME/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH
$ echo $JAVA_HOME
/usr/local/java/jdk1.8.0_101
$ java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
$ ls /usr/local/java/
jdk1.7.0_79/ jdk1.8.0_101/
Why is my java version still jdk7?
Ubuntu has ability to work with multiple java versions. In your case, it just means that it has both JDK 7 and JDK 8 installed in your system but is using JDK 7.
To switch from one java version to another, you can use sudo update-alternatives --config java. This will list all JDKs installed in your system, just enter the number corresponding to JDK 8 and it should switch to JDK 8.
Run which java in your command shell. That will tell you where the java command you are running is coming from.
I suspect that is will tell you "/usr/bin/java" ... because this:
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
puts your new bin directories onto the end of the search path, not the beginning.
However, the better way to do this would be to use alternatives as suggested by another Answer. (With a custom installation in "/usr/local" this will require some fiddling around to get "alternatives" to understand the alternative.)
I upgraded java on my osx 10.9.4 machine using the suggested method from the java web site
It successfully updated, but when trying to run Eclipse I get an error:
Version 1.6.0_65 of the JVM is not suitable for this product.
Version 1.7 or greater is required.
When I access java settings through the applet in the control panel, it shows Java 7 Update 65, but when I type java -version in the console, it shows 1.6.0_65 (response shown below):
| => java -version
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode)
As far as I know, there is only one java on the box. "which java" returns /usr/bin/java and type -a java returns only /usr/bin/java also. /usr/bin/java is obviously the older version, but I'd like to use the updated one. Can someone please tell me how to update the /usr/bin/java version and/or how to link the applet version so that Eclipse will use the updated one?
Take a look at oracle documentation here:
http://docs.oracle.com/javase/7/docs/webnotes/install/mac/mac-jdk.html
It says:
To run a different version of Java, either specify the full path, or
use the java_home tool:
/usr/libexec/java_home -v 1.7.0_06 --exec javac -version
The /usr/libexec/java_home is a link to your jdk directory that should be located under:
/Library/Java/JavaVirtualMachines/jdk<major>.<minor>.<macro[_update]>.jdk
I think your java_home link is pointing to your jdk6. You can check it doing a ls -l /usr/libexec/
I have downloaded Java on mac mavericks system. But when I type on terminal to see the Java version using command:
java version
I get the following error
Could not find or load main class version
I went to oracle website and tried a check to see if Java is installed on my system,which confirmed the Java7 is installed on the system. But why can I not see version in terminal?
Try
java -version
Without the minus sign it is trying to load a program called version.
java –version
will cause the same error (copied from webpage) as "–" is an em dash
java -version is the command to check java version
Download latest Java SE from Oracle site and install it. Then reopen cmd and check java version using java -version.
Set the Java path to bin and check it's version also. Both java and javac should be on same version.
In my case:
C:\Users\darshan>java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
C:\Users\darshan>javac -version
javac 1.8.0_121
i have cgywin and java 7 installed on window 7, also updated the system environment variable to point to the right java version, however when I run commands in cgywin, I m not sure which java it use, here is the commands and results:
$ java -version
java version "1.7.0_09"
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) Client VM (build 23.5-b02, mixed mode)
$ javac -version
javac 1.7.0_17
$ which java
/cygdrive/c/Windows/system32/java
export
declare -x JAVA_HOME="C:\\Program Files\\Java\\jdk1.7.0_17"
why all the versions are different?
Your PATH has two directories where it can find java one is under windows which picks a version installed (I imagine using the registry) and another is in your JDK. There is no javac in your Windows directory so it finds the on in your JDK.
To keep things simple I would just have one version of Java 7 JDK installed unless you really need multiple versions. I would change your path so it have the version of Java you want first, rather than near the end.
There are two varieties of JRE available. Java VM: IBM vs. Sun.
Is there a way to know which JRE I am using through JavaScript or some Java issued command.
The following command will tell you a lot of information about your java version, including the vendor:
java -XshowSettings:properties -version
It works on Windows, Mac, and Linux.
System.out.println(System.getProperty("java.vendor"));
System.out.println(System.getProperty("java.vendor.url"));
System.out.println(System.getProperty("java.version"));
Sun Microsystems Inc.
http://java.sun.com/
1.6.0_11
http://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html
Open up your:
command prompt if you're using Windows
terminal if you're using mac or Linux
Type in:
java -version // This will check your JRE version
javac -version // This will check your Java compiler version if you installed the JDK
Grab a cup of coffee and you're done! You don't need to add the .exe to the java -version if everything is installed correctly.
In Linux:
java -version
In Windows:
java.exe -version
If you need more info about the JVM you can call the executable with the parameter -XshowSettings:properties. It will show a lot of System Properties. These properties can also be accessed by means of the static method System.getProperty(String) in a Java class. As example this is an excerpt of some of the properties that can be obtained:
$ java -XshowSettings:properties -version
[...]
java.specification.version = 1.7
java.vendor = Oracle Corporation
java.vendor.url = http://java.oracle.com/
java.vendor.url.bug = http://bugreport.sun.com/bugreport/
java.version = 1.7.0_95
[...]
So if you need to access any of these properties from Java code you can use:
System.getProperty("java.specification.version");
System.getProperty("java.vendor");
System.getProperty("java.vendor.url");
System.getProperty("java.version");
Take into account that sometimes the vendor is not exposed as clear as Oracle or IBM. For example,
$ java version
"1.6.0_22" Java(TM) SE Runtime Environment (build 1.6.0_22-b04) Java HotSpot(TM) Client VM (build 17.1-b03, mixed mode, sharing)
HotSpot is what Oracle calls their implementation of the JVM. Check this list if the vendor does not seem to be shown with -version.
The Java system property System.getProperty(...) to consult is "java.runtime.name". This will distinguish between "OpenJDK Runtime Environment" and "Java(TM) SE Runtime Environment". They both have the same vendor - "Oracle Corporation".
This property is also included in the output for java -version.
Open a command prompt:
Version: java -version
Location: where java (in Windows)
which java (in Unix, Linux, and Mac)
To set Java home in Windows:
Right click on My computer → Properties → Advanced system settings → Environment Variable → System Variable → New.
Give the name as JAVA_HOME and the value as (e.g.) c:\programfiles\jdk
Select Path and click Edit, and keep it in the beginning as:
%JAVA_HOME%\bin;...remaining settings goes here
Git Bash + Windows 10 + Software that came bundled with its own JRE copy:
Do a "Git Bash Here" in the jre/bin folder of the software you installed.
Then use "./java.exe -version" instead of "java -version" to get the
information on the software's copy rather than the copy referenced by your PATH environment variable.
Get the version of the software installation: ./java.exe -version
JMIM#DESKTOP-JUDCNDL MINGW64 /c/DEV/PROG/EYE_DB/INST/jre/bin
$ ./java.exe -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
Get the version in your PATH variable: java -version
JMIM#DESKTOP-JUDCNDL MINGW64 /c/DEV/PROG/EYE_DB/INST/jre/bin
$ java -version
java version "10" 2018-03-20
Java(TM) SE Runtime Environment 18.3 (build 10+46)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10+46, mixed mode)
As for addressing the original question and getting vendor information:
./java.exe -XshowSettings:properties -version ## Software's copy
java -XshowSettings:properties -version ## Copy in PATH
I had a problem where my Java applications quit work with no discernible evidence that I could find. It turned out my system started using the 64-bit version rather than the 32-bit version was needed (Windows Server 2012). In Windows, the command:
Javaw -version
just brought me back to the command prompt without any information. It wasn't until I tried
Javaw -Version 2>x.txt
type x.txt
that it gave me what was being executed was the 64-bit version. It boiled down to my PATH environment variable finding the 64-bit version first.
As you are expecting it to know using the Javascript, I believe you want to know the JRE versioned being used in your browser. Hence you can include Java version tester applet which can exactly tell you the version of the current browser.
import java.applet.*;
import java.awt.*;
public class JavaVersionDisplayApplet extends Applet
{
private Label m_labVersionVendor;
public JavaVersionDisplayApplet() // Constructor
{
Color colFrameBackground = Color.pink;
this.setBackground(colFrameBackground);
m_labVersionVendor = new Label (" Java Version: " +
System.getProperty("java.version") +
" from "+System.getProperty("java.vendor"));
this.add(m_labVersionVendor);
}
}
To check actually runned Java version you can use java.lang.Runtime API available since Java 10.
Runtime.Version version = Runtime.version();
int javaVersion = version.feature();
// returns 17 for Java 17