I have installed JAVA 1.7_80 in my centOS machine, but when I check the Java version it shows 1.7_09.
I ran the ./java -version in the installation directory which correctly shows 1.7_80, but the global java -version is 1.7_09.
Please refer the link for image -
https://scontent.xx.fbcdn.net/hphotos-xft1/v/t1.0-9/11667333_914348581933741_3461411661734554342_n.jpg?oh=e8d3037e2f6492757b0f786bd0ae8f77&oe=56318F12
Does someone know what could be the cause or how to fix this?
There's default OpenJDK in CentOS,
OPTION A
You have to install JDK with alternatives.
# cd /opt/jdk1.8.0_101/
# alternatives --install /usr/bin/java java /opt/jdk1.8.0_101/bin/java 2
# alternatives --config java
THE OUTPUT ==>
There are 2 programs which provide 'java'.
Selection Command
-----------------------------------------------
1 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64/jre/bin/java
+ 2 /opt/jdk1.8.0_101/bin/java
Enter to keep the current selection[+], or type selection number:
Select the version you want from this list.
OR : OPTION B
#ls -l /usr/bin/java
OUTPUT : . 1 root root 22 සැප් 9 02:09 /usr/bin/java -> /etc/alternatives/java
then # ls -l /etc/alternatives/java
OUTPUT : . 1 root root 26 සැප් 9 02:09 /etc/alternatives/java -> /opt/jdk1.8.0_101/bin/java
#unlink /etc/alternatives/java
#ln -s <new location> /etc/alternatives/java
(ln -s <original file> <link to file> )
But I prefer the option A.
Related
I'm getting an error when setting the $JAVA_HOME variable on my CentOS system.
Not sure what causing Java to be unrecognized, this is a new VM provisioned with no issues observed.
[Khurum#localhost bin]$ sudo update-alternatives --config java
[sudo] password for Khurum:
There is 1 program that provides 'java'.
Selection Command
-----------------------------------------------
*+ 1 java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.275.b01-1.el8_3.x86_64/jre/bin/java)
Enter to keep the current selection[+], or type selection number: ^C
[Khurum#localhost bin]$ export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.275.b01-1.el8_3.x86_64/jre/bin/java
[Khurum#localhost bin]$ echo $JAVA_HOME
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.275.b01-1.el8_3.x86_64/jre/bin/java
[Khurum#localhost bin]$ ./elasticsearch
could not find java in JAVA_HOME at /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.275.b01-1.el8_3.x86_64/jre/bin/java/bin/java
You are setting your JAVA_HOME incorrectly; it should point to the folder, not the Java executable:
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.275.b01-1.el8_3.x86_64/
I can locate java in my machine in etc/alternatives/java(link to executable file to /usr/local/java/jdk1.8.0_201/bin/java where I can see executable java file).
Kindly please help me to move this java file to usr/bin/java directory.
As lot of dependant applications are failing to run because of this.
Thanks
Pritam
This is because there are some 32-bit libraries missing in your Ubuntu 64-bit. Run:
apt-get install libc6-i386
This is the setup you are looking for. I am surprised that the install process didn't do this for you. You need the Unix ln -s command.
$ file /usr/bin/java
/usr/bin/java: symbolic link to /etc/alternatives/java
$ ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 Apr 18 2018 /usr/bin/java -> /etc/alternatives/java
# java -version
-bash: java: command not found
I have jdk1.8.0_40 this folder in usr/local.
When I navigate to the folder and type alternatives --config jar, I get such output
There is 1 program that provides 'jar'.
Selection Command
-----------------------------------------------
*+ 1 /opt/jdk1.8.0_40//bin/jar
Enter to keep the current selection[+], or type selection number:
These are the content in jdk
bin include lib README.html THIRDPARTYLICENSEREADME-JAVAFX.txt
COPYRIGHT javafx-src.zip LICENSE release THIRDPARTYLICENSEREADME.txt
db jre man src.zip
You need to add your installation path to your PATH variable. Bash only looks for executables in the paths defined by your PATH variable.
You need to install java first:
alternatives --install /usr/bin/java java <path to java>
Change the var in above command to appropriate location of you java file, for example: /usr/local/jdk/bin/java
And then run the following command to set it as default java:
alternatives --config java
I'm using Java 8 update 45 on my mac.
I've tried to use 'jdeps' command, but my mac keeps showing "command not found" message. Weird thing is that other command in the bin folder like 'java', 'javac' perfectly works. Only 'jdeps' command is not working.
How can I use jdeps command? Is there any condition to use this command?
It's definitely there in the version I have on Mac:
/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin
The crux the it seems to be that some of the things in the above don't get the magic mentioned below:
http://lists.apple.com/archives/java-dev/2015/Nov/msg00009.html
When the JAVA_HOME environment variable is set Mac OS X does some magic
But the problem is not all the commands are covered, and some are missing from newer JDKs
The links don't appear in:
$ ls -l `which java`
lrwxr-xr-x 1 root wheel 74 1 Jul 2014 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk_version/Contents/Home
export PATH=${PATH}:${JAVA_HOME}/bin
I have jdk installed under "/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java"
When i do a "which java", it returns "/usr/bin/java"
But, I want which java to return /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java, instead of /usr/java/bin
How can this be done? and what is happening behind the scenes?
It may be that /usr/bin/java is a symbolic link.
Try
ls -l `which java`
This will run an ls -l on the output of 'which java', hopefully giving you the full path pointed to by the link.
/usr/bin/java is a symlink:
/usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
If you use:
/usr/libexec/java_home -v
You can confirm whether or not it's using 1.6.0:
/Library/Java/JavaVirtualMachines/jdk1.6.0.jdk/Contents/Home