Java in usr/bin/java missing - java

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

Related

JAVA_HOME file is not working and I couldn't update Java to 1.8 on Amazon EC2

I have an Amazon EC2 t3.medium instance on Linux.
I am trying to run Apache ni-fi on this instance and I need java.
When I check the JAVA_HOME default:
$ echo$JAVA_HOME
-bash: echo/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.261-2.6.22.2.amzn2.0.2.x86_64: No such file or directory
Then, I downloaded java 1.8 by the following comamnds on terminal:
$ sudo yum install java-1.8.0-openjdk.x86_64
$ sudo update-alternatives --config java
(I selected 2 for java 1.8)
To find the location of my java file, I run them:
$ file $(which java)
/usr/bin/java: symbolic link to `/etc/alternatives/java'
$ file /etc/alternatives/java
/etc/alternatives/java: symbolic link to `/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.amzn2.0.2.x86_64/jre/bin/java'
$ file /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.amzn2.0.2.x86_64/jre/bin/java
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.amzn2.0.2.x86_64/jre/bin/java: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 3.2.0, BuildID[sha1]=1b1c0fd721197a04f9bfc9b0891f1bd83a5f49d5, not stripped
I guess it is working properly. Then, I change JAVA_HOME from 1.7 to 1.8 by writing these commands on terminal for both ec2-user and root:
[root#ip-178-32-11-247 ~]# export JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.amzn2.0.2.x86_64"
[root#ip-178-32-11-247 ~]# PATH=$JAVA_HOME/bin:$PATH
In advance, I have setup nifi on root. And in nifi-1.16.0 directory, I am trying to run this command:
[root#ip-178-32-11-247 nifi-1.16.0]# bin/nifi.sh start
The Error message is:
Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.amzn2.0.2.x86_64
NiFi home: /root/nifi-1.16.0
Bootstrap Config File: /root/nifi-1.16.0/conf/bootstrap.conf
bin/nifi.sh: line 401: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.amzn2.0.2.x86_64/bin/java: No such file or directory
I thought that java is working but JAVA_HOME couldn't setup properly but I couldn't solve that. What should I do at that point to solve the problem and start nifi?
I will be appreciated very much if you can help, I coludn't start my term project because of this error :(
The correct path for JAVA_HOME should be /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.amzn2.0.2.x86_64/jre/bin/java
export JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.amzn2.0.2.x86_64/jre/bin/java"
But probably you don't need to export JAVA_HOME anyway. You should have a link in /usr/bin/. You can check this by doing the following:
[ssm-user#ip-172-31-85-243 bin]$ which java
/usr/bin/java
By default Apache Nifi is using the executable /usr/bin/java, so you don't need to export JAVA_HOME.

Cannot find jdeps command (Mac)

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

which java command should return custom java installation path

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

Can't find/install libXtst.so.6?

I'm running Ubuntu 12.10 and I'm trying to install Netbeans 7.1(or later)
I have the .sh file, but it won't install, the error appears here:
[2013-06-27 19:11:28.918]: at org.netbeans.installer.Installer.main(Installer.java:81)
[2013-06-27 19:11:28.918]: An error occured while initializing the NetBeans IDE installer UI.
[2013-06-27 19:11:28.918]: Most probably the running JVM is not compatible with the current platform.
[2013-06-27 19:11:28.919]: See FAQ at http://wiki.netbeans.org/FaqUnableToPrepareBundledJdk for more information.
[2013-06-27 19:11:28.919]: /usr/local/java/jre1.7.0_25/lib/i386/xawt/libmawt.so: libXtst.so.6: cannot open shared object file: No such file or directory
[2013-06-27 19:11:28.919]:
[2013-06-27 19:11:28.919]: Exception:
[2013-06-27 19:11:28.919]: java.lang.UnsatisfiedLinkError:
[2013-06-27 19:11:28.919]: /usr/local/java/jre1.7.0_25/lib/i386/xawt/libmawt.so: libXtst.so.6: cannot open shared object file: No such file or directory
[2013-06-27 19:11:28.919]:
[2013-06-27 19:11:28.919]: You can get more details about the issue in the installer log file:
[2013-06-27 19:11:28.919]: /root/.nbi/log/20130627191128.log
I don't have the libXtst.so.6 file in any directory, and I can't seem to find it anywhere to download. Has anyone else run into this problem, or know a work around?
EDIT: As mentioned by Stephen Niedzielski in his comment, the issue seems to come from the 32-bit being of the JRE, which is de facto, looking for the 32-bit version of libXtst6. To install the required version of the library:
$ sudo apt-get install libxtst6:i386
Type:
$ sudo apt-get update
$ sudo apt-get install libxtst6
If this isn’t OK, type:
$ sudo updatedb
$ locate libXtst
it should return something like:
/usr/lib/x86_64-linux-gnu/libXtst.so.6 # Mine is OK
/usr/lib/x86_64-linux-gnu/libXtst.so.6.1.0
If you do not have libXtst.so.6 but do have libXtst.so.6.X.X create a symbolic link:
$ cd /usr/lib/x86_64-linux-gnu/
$ ln -s libXtst.so.6 libXtst.so.6.X.X
This worked for me in Luna elementary OS
sudo apt-get install libxtst6:i386
Your problem comes from the 32/64 bit version of your JDK/JRE... Your shared lib is searched for a 32 bit version.
Your default JDK is a 32 bit version. Try to install a 64 bit one by default and relaunch your `.sh file.
Had that issue on Ubuntu 14.04, In my case I had also libXtst.so missing:
Could not open library 'libXtst.so': libXtst.so: cannot open shared object
file: No such file or directory
Make sure your symbolic link is pointing to proper file,
cd /usr/lib/x86_64-linux-gnu and list libXtst with:
ll |grep libXtst
lrwxrwxrwx 1 root root 16 Oct 7 2016 libXtst.so.6 -> libXtst.so.6.1.0
-rw-r--r-- 1 root root 22880 Aug 16 2013 libXtst.so.6.1.0
Then just create proper symbolic link using:
sudo ln -s libXtst.so.6 libXtst.so
List again:
ll | grep libXtst
lrwxrwxrwx 1 root root 12 Sep 20 10:23 libXtst -> libXtst.so.6
lrwxrwxrwx 1 root root 12 Sep 20 10:23 libXtst.so -> libXtst.so.6
lrwxrwxrwx 1 root root 16 Oct 7 2016 libXtst.so.6 -> libXtst.so.6.1.0
-rw-r--r-- 1 root root 22880 Aug 16 2013 libXtst.so.6.1.0
all set!
I had this issue with CentOS 8 and all of the packages above did not solve my problem. When I reviewed the two folders that store these files (for 64 bit /usr/lib64/ vs 32 bit /usr/lib/) I found that the 64-bit folder did not have libXt (but I was on a 64 bit OS). So I ran:
yum install -y libXt.x86_64
And this resolved my problem. libXt.so.6 was now in that directory.

"Error: JAVA_HOME is not defined correctly." in building Jikes rvm

When I built the Jikes RVM on Ubuntu, I got this error. Any idea?
bin/buildit localhost production
---> Config: production
/bin/bash --login -c '/bin/bash --login -c " cd /home/jack/Programs/jikesrvm-3.1.2 && export JAVA_HOME=/opt/jdk1.6.0 && ant very-clean -Dhost.name=ia32-linux && ant check-components-properties -Dhost.name=ia32-linux -Dtarget.name=ia32-linux -Dcomponents.cache.dir=/home/jack/.buildit_components_cache && ant -Dtarget.name=ia32-linux -Dconfig.name=production -Dhg.revision= -Dhost.name=ia32-linux -Dcomponents.cache.dir=/home/jack/.buildit_components_cache "'
Error: JAVA_HOME is not defined correctly.
We cannot execute /opt/jdk1.6.0/bin/java
Wed Jun 13 12:23:37 EDT 2012
===================== Summary =====================
Local : /home/jack/Programs/jikesrvm-3.1.2
Build : ubuntu:/home/jack/Programs/jikesrvm-3.1.2
Target : ubuntu:/home/jack/Programs/jikesrvm-3.1.2
Start : Wed Jun 13 12:23:37 EDT 2012
Config : production [FAILED Wed Jun 13 12:23:37 EDT 2012]
===================================================
OS:
Linux ubuntu 2.6.32-24-generic #39-Ubuntu SMP Wed Jul 28 06:07:29 UTC 2010 i686 GNU/Linux
Environmental Variables:
PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/jvm/java-6-sun-1.6.0.22/bin<
JAVA_HOME
/usr/lib/jvm/java-6-sun-1.6.0.22
I checked the java in the JAVA_HOME/bin directory, it works.
No matter how I change the environmental variables, the error kept complaining
"We cannot execute /opt/jdk1.6.0/bin/java".
It seems that I didn't modify the right "position".
run this command:
find . -exec grep "jdk1.6.0" {} \;
To find out which file is setting JAVA_HOME to that path.
While you build jikes you can either build it using ant or using the command you are using.
If the JAVA_HOME problem is causing trouble use
bin/buildit localhost production -j"path to your jvm directory"
-This is present in "/usr/bin/jvm".
Another method: There is bin/buildit.base_config in which path for JAVA_HOME is specifically mentioned. So under "# Default JAVA_HOME values" you can modify appropriate location, for example,
global.javahome.ppc32-linux=/usr/lib/jvm/java-6-sun-1.6.0.26
global.javahome.ppc64-linux=/usr/lib/jvm/java-6-sun-1.6.0.26
global.javahome.ia32-linux=/usr/lib/jvm/java-6-sun-1.6.0.26
global.javahome.x86_64-linux=/usr/lib/jvm/java-6-sun-1.6.0.26
You can chose which you want to use. If not familiar with your architecture, modify all and now you can build without having to worry about your java path to be mentioned explicitly.
For more detailed information check this blog
I have also written a small article on how one can start to fiddle with Jikes
It's JRE but not JDK. Install JDK and make JAVA_HOME pointing to it.
You might get this error due to couple of reasons. To fix this quickly please follow below steps,
First find the java location. To get a list of your installed Java platforms, run the following command from the terminal:
$ sudo update-alternatives --config java
Now set JAVA_HOME and PATH,
$ export JAVA_HOME=<java_home>
$ export PATH=$JAVA_HOME/jre/bin:$PATH
Create the symlink
$ sudo ln -s <java_home>/jre <java_symlink_path>
When we take your case as a example :
$ sudo ln -s /usr/lib/jvm/java-6-sun-1.6.0.22/jre /opt/jdk1.6.0
Above command will create the symlink location where the system is trying to find in your issue.
Finally do the try your app.

Categories