Cloudera - JAVA_HOME not set - java

I am pretty novice when it comes to Ubuntu but I am trying to follow along with the install instructions for Cloudera located here.
At step 1, I am getting to following error:
brock#brock-hpserver:~$ sudo -u hdfs hdfs namenode -format
Error: JAVA_HOME is not set and could not be found.
However, although I could be wrong, I believe I have everything set up properly:
brock#brock-hpserver:~$ echo $JAVA_HOME
/usr/lib/jvm/java-6-openjdk-amd64
brock#brock-hpserver:~$ echo $PATH
/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:JAVA_HOME/bin
And finally my java version:
brock#brock-hpserver:~$ java -version
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.5) (6b24-1.11.5-0ubuntu1~12.04.1)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
Any help will be greatly appreciated. I simply just want to poke around and learn Hadoop on a spare machine at home.

I met the same problem, just add JAVA_HOME="directory_to_JDK" setting into the /etc/environment, and it works.

The JAVA_HOME is defined for your process, but not for the process in which the sudo is running. export the JAVA_HOME definition. I don't recall the syntax, but I believe it's similar to export JAVA_HOME=/drive/dir1/dir2/java
If that does not work, JAVA_HOME can be defined at the system level, for all processes. It's been a long time, I don't recall how. But hopefully there's enough here to allow you to Google.
Here's a SO link about export.

Related

Elasticsearch: could not find java in bundled jdk at .../jdk/bin/java

When I try to run .bin/elasticsearch, I get the following error:
could not find java in bundled jdk at /home/ubuntu/Elastic
Search/elasticsearch-7.8.0/jdk/bin/java
I have absolutely no idea what's going on. I know this topic has been created before, but I haven't found a way to fix. For java -version I get:
openjdk version "1.8.0_265"
OpenJDK Runtime Environment (build 1.8.0_265-8u265-b01-0ubuntu2~20.04-b01)
OpenJDK 64-Bit Server VM (build 25.265-b01, mixed mode)
Can anyone help me please? Thank you!
The most probable reason for the above error is that JAVA_HOME is not set
To display JAVA_HOME variable path, run this command echo $JAVA_HOME
If nothing appears then follow the below steps:
To see all the java versions installed in Ubuntu, use this command:
sudo update-alternatives --config java
Set your java path using this. - export JAVA_HOME=<YOUR-JAVA-PATH>
I had the similar problem on linux, when I was running elasticsearch using
sh elasticsearch
I got the error
Elasticsearch: could not find java in bundled jdk at .../jdk/bin/java
Then I referred to the official document
and set ES_JAVA_HOME environment variable.
After running elasticsearch again, I got the following message and it ran successfully
ignoring JAVA_HOME=/project/jdkForElasticSearch/; using ES_JAVA_HOME
Note: After setting environment variable, restart your terminal to reflect the updated value in it.

Unable to locate an executable at "/Library/Java/JavaVirtualMachines/..."

I want to install an NPM express generator:
sudo apt npm install -g express-generator
It throws the following error:
Unable to locate an executable at "/Library/Java/JavaVirtualMachines/openjdk-14.0.1.jdk/Contents/Home/bin/apt" (-1)
I installed Java in this path (it's not in the System/Library/ - maybe thats the issue?):
'MacintoshSSD/Library/Java/JavaVirtualMachines/openjdk-14.0.1.jdk/Contents/Home'
My .bash_profile looks like that:
export JAVA_HOME=$(/usr/libexec/java_home)
If I check JAVA_HOME it looks fine:
echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/openjdk-14.0.1.jdk/Contents/Home
.. and Java version:
java --version
openjdk 14.0.1 2020-04-14
OpenJDK Runtime Environment (build 14.0.1+7)
OpenJDK 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing)
Any idea why it still can find an exectuable?
I an other thread I read about a possible conflict between the pre-installed macOS Java-Version and the Orcalce Java-Version enter link description here but I couldn`t work it out..
And could you explain to me the difference between java_home and JAVA_HOME?
Sorry, I just saw what's wrong...
There used to be an apt tool in Java, but it's gone now. Your mistake is using the linux command line. On many linux systems, another tool called apt is used for installing software.
Check the npm documentation on how to install npm on your Mac, as there are different ways to do it.
Once npm is installed, run sudo npm install -g express-generator (no apt here).
Explanation of the error message
The Java apt-tool was removed in JDK 8. But as JAVA_HOME/bin is normally not on your PATH on Mac, apple provides simple wrappers for all the commands under JAVA_HOME. There still is such a wrapper for apt that tries to run a program with the same name from your Java installation. That's why you get that error message.
conflict between the pre-installed macOS Java-Version and the Orcalce Java-Version:
Apple stopped pre-installing Java in macOS 10.7 so this should not be an issue.
difference between java_home and JAVA_HOME:
JAVA_HOME is an environment variable that points to your Java installation. java_home is a utility program in macOS that makes it easier to correctly set up your JAVA_HOME by listing installed Java versions and the values to use for JAVA_HOME.

Java Axis 2 Script wont start without JAVA_HOME Mac OS

Hello guys this is the first time i write a question here and not just read an answer.
My problem is that I have a Macbook with Sierra on it and hava a tomcat with my wsdl file and i wanted to generate my classes with axis2 so i started the wsdl2java.sh in Eclipse and till that point everything works fine.
But then it says:
You must set the JAVA_HOME variable before running Axis2 Script.
but when i open a terminal and lookup for
echo $JAVA_HOME it will say:
/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home
and also when i type in java -version i get this result:
java version "1.8.0_101" Java(TM) SE Runtime Environment (build
1.8.0_101-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)
my question is why does eclipse not found my JAVA_HOME path?
i allready started eclipse as sudo directly through the terminal and also tried to change the .bash_profile but nothing works for me
I hope i described the Problem so that you can help me !
thanks a lot
As Minh Kieu recommended in the comments, I added this to the shell script of wsdl2java:
export JAVA_HOME=$(/usr/libexec/java_home)
Then I restarted Eclipse and now it worked.

Problems with Java installation (making using Spark difficult)

I am trying to get Spark running locally. When I launch it, I get the following error, suggesting something is weird with my java installation (or the path to it). This is on Mac OS Yosemite.
line 190: /usr/java/jdk1.7.0_51/bin/java/bin/java/bin/java: No such file or directory
Any suggestions how to remedy this? Let me know if you need more info (I don't know where to start)
Edit: Clearly there is a setting wrong somewhere, I'm just not sure where.
In my bash-profile, there is a line
JAVA_HOME=usr/bin/java
Also when I run java -version I get:
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)
Solution:
Something was weird with where Spark was looking for Java. Not sure how the default is set, but I found a way to override it.
1) In terminal run this and copy and paste the results. This gives you the path of your Java installation.
$(dirname $(readlink $(which javac)))/java_home
2) In the spark-whatever/conf folder, make a file "spark-env.sh" and write "export JAVA_HOME="

Installing CPLEX on Mac: No Java virtual machine could be found

I try to install CPLEX on my Mac. When I open terminal and type
chmod +x /Users/MarjoleinKroon/Downloads/cplex_studio126.osx.bin
/Users/MarjoleinKroon/Downloads/cplex_studio126.osx.bin
I get the following error
Preparing to install...
Extracting the installation resources from the installer archive...
Configuring the installer for this system's environment...
/Users/MarjoleinKroon/Downloads/cplex_studio126.osx.bin: line 2374: Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java: No such file or directory
/Users/MarjoleinKroon/Downloads/cplex_studio126.osx.bin: line 2374: Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java: No such file or directory
No Java virtual machine could be found from your PATH
environment variable. You must install a VM prior to
running this program.
I searched the internet to solve this problem, and I found several things to check. If I type java -version I get
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)
So it seems like java is installed properly. Furthermore, when I type /usr/libexec/java_home -V, a VM seems to be there:
Matching Java Virtual Machines (1):
1.8.0_40, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home
Online I read something about PATHs, but I have not enough knowledge to understand this exactly. However, if I type echo $PATH I get
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/texbin
I don't know what this means, but it seems kind of strange to me.
Can anyone help me? Please be as clear as possible, because I don't have a lot of knowledge concerning this. Thanks in advance!

Categories

Resources