I set my JAVA_HOME variable the follow path: /usr/lib/jvm/jdk11 and when i put the following comand: java -version , it shows me the current version and echo $JAVA_HOME indicates the above path.
When I start tomcat the following error message comes up:
neither JAVA_HOME nor JRE_HOME variable defined.
I setting up everything right, but the tomcat cant find it.
Tomcat calls a script, setenv.sh, from catalina.sh.
Create a script called setenv.sh in the directory CATALINA_BASE/bin, and add the line: "export JAVA_HOME=/usr/lib/jvm/jdk11". Make the script executable, i.e. chmod +x setenv.sh
You will need to add the following line in your .bashrc file:
export PATH=$PATH:$JAVA_HOME/bin
The .bashrc file is located in the /home directory.
Related
I was trying to run ./gradlew bootRun in both Git Bash and PowerShell, and got this error: ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jre1.8.0_121
The gradlew file is inside the project directory that cloned from git. It is a practice project from Spring official guide. There's also a gradle.bat file with these lines:
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%\bin\java.exe
I also tried to run Eclipse EE, which got no problem. The environment setting should be no problem.
In addition to Ernest's answer, the JAVA_HOME it wants is the actual directory, not the bin folder like the path wants for javac. Took me a while to work that out
Looks like your JAVA_HOME variable resolves to a JRE installation directory. But as you're talking about Gradle, you're surely trying to build/compile code.
If you have a JDK installed, change JAVA_HOME variable to point to it. The folder name should typically start with "jdk". Otherwise, you have to install a Java Development Kit.
You could also try exporting the variable manually before running gradle on the command line (SET JAVA_HOME=<path to the jdk directory>)
Please set the JAVA_HOME variable location to the path to JDK instead of JRE.
If that is correctly set, check the environment variables in Edit mode.
In my case, I found that a semicolon was appended to the JAVA_HOME environment variable at the end.
To check:
Open the environment variables list.
Select the variable and click Edit.
Remove the semicolon and Save.
Closed the settings and checked the path in cmd using echo %JAVA_HOME%, and ran gradle -v.
It ran perfectly.
Note: Check the variable value by clicking the Edit button as we cannot see the semicolon instead. Windows adds a semicolon so that the same variable can be used as the path to multiple locations.
Added picture for reference:
Found a solution I hadn't seen before in my googling.
Open up your gradlew.bat in some editor. On line 34-ish you will see this:
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%\bin\java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
add this line to the error message: echo %JAVA_EXE%
so it looks like this
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo %JAVA_EXE%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
Then run your gradlew.bat file.
The error should now appear again, but with the added echo of the path to JAVA_EXE. In my case it was echoing \bin\java.exe and NOT the full path C:\...\Java\jre1.8.0_251\bin\java.exe
to fix this, I changed
set JAVA_EXE=%JAVA_HOME%\bin\java.exe
to
set JAVA_EXE=C:\...\Java\jdk1.8.0_261\bin\java.exe
The value is now hardcoded, true, but it worked. I don't know why gradle doesn't concat the variable name into the path.
I've found myself with the same issue, although my JAVA_HOME was set to the correct JDK path.
However Windows 10 appended a semicolon at the end of the path.
This way the JAVA_HOME variable would work anywhere but not with Gradle.
I'm posting this, because it might spare someone else the time I've been looking for it ;)
If you didn't have admin rights, override the JAVA_HOME in User Environment Variable. Avoid typo by selecting the Java home folder. You must include folder before the bin ( do not include /bin) for java home.
If none of the above works open the gradle.bat file in an editor and make sure that IT is correct , in my case gradle was the problem
I've downloaded java jdk1.8.0.7.tar.gz file from the official website and unzipped it into my home directory. Now to set the $JAVA_HOME variable I used the follwing commands command nano .bashrc and then appending export $JAVA_HOME=/home/shivam/Java/jdk1.8.0.7 at the end of the file . But whenever I run the command sudo $CATALINA_HOME/bin/startup.sh I get an error message saying
Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program
I don't understand why it is unable to find the java path though I've installed tomcat and set its home variable the this way, which worked.
I wan't to install Java manually without using apt-get. Kindly guide .
You want to append the following to .bashrc:
JAVA_HOME=/home/shivam/Java/jdk1.8.0.7
Note the missing $ at the start.
Also remember that the file won't effect your current shell without sourceing it first.
Also, when running a command with sudo, you are running it as the root user, not as yourself. So the environment variable needs to be set for the root user, not yourself.
You can run sudo env | grep JAVA_HOME to see whether it is set for root.
Have you run .bashrc ?
source .bashrc
Try add the following 2 lines in your .bashrc file:
JAVA_HOME=/home/shivam/Java/jdk1.8.0.7/
export JAVA_HOME
I enter this command and the it gives back this error
`bin/hadoop jar
share/hadoop/mapreduce/hadoop-mapreduce-examples-2.6.0.jar grep input
output 'dfs[a-z.]+'
bin/hadoop: line 144: /usr/local/java/jdk1.8.0_40/jre/bin/bin/java: No
such file or directory`
please help.
Looks like you're trying to set Hadoop. You should find where Java is installed in your machine, then go to
/etc/<hadoop>/<conf>/hadoop-env.sh
and change JAVA_HOME to where Java is installed.
In order to know where Java is installed, try to echo $JAVA_HOME (if it's set it'll show the path), if not, try to search for it:
sudo find /usr/ -name *jdk
Now I've noticed that you have a double /bin in the path, change the JAVA_HOME and remove the redundant /bin.
Path /usr/local/java/jdk1.8.0_40/jre/bin/bin/java has /bin/bin twice. It shows that PATH environment or JAVA_HOME variable is wrongly configured. Check that path specified in PATH variable should be /usr/local/java/jdk1.8.0_40/jre/bin or JAVA_HOME = /usr/local/java/jdk1.8.0_40/jre
I installed hadoop watching a youtube video.
while I try to run this in terminal it gives me this error
$ /usr/local/hadoop-2.6.0/bin/hadoop version
/usr/local/hadoop-2.6.0/bin/hadoop: line 144: /usr/iib/java/jdk1.8.0_31/bin//bin/java: No such file or directory
I have java in /usr/lib/java/jdk1.8.0_31/bin/ but I dont know why the error is showing a different path.
I have setup the path in hadoop-env.sh like this
JAVA_HOME=/usr/iib/java/jdk1.8.0_31/bin/
export JAVA_HOME=${JAVA_HOME}
I did the same in .bashrc
export HADOOP_HOME=/usr/local/hadoop-2.6.0/bin/hadoop
JAVA_HOME=/usr/iib/java/jdk1.8.0_31/bin
export JAVA_HOME
PATH=$PATH:$JAVA_HOME
export PATH
Please help me. if you need any extra info please ask.
Your JAVA_HOME should point to /usr/iib/java/jdk1.8.0_31 and not the bin folder under it.
Also, usually it would be lib and not iib.
The PATH should include the $JAVA_HOME/bin, though.
You need to change JAVA_HOME from:
JAVA_HOME=/usr/iib/java/jdk1.8.0_31/bin/
TO
JAVA_HOME=/usr/iib/java/jdk1.8.0_31
i.e. Remove bin directory from JAVA_HOME variable.
And change PATH from:
PATH=$PATH:$JAVA_HOME
TO
PATH=$PATH:$JAVA_HOME/bin
Ok. I saw you problem.you may be no install jdk or your jdk's path is wrong.
now you can test it :
test you jdk location: whereis java
found your path and type it:export JAVA_HOME=/usr/iib/java/jdk1.8.0_31/
export JRE_HOME=/usr/iib/java/jdk1.8.0_31
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$ClASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
done it .Then you type hadoop path
all type in ~/.bashrc
I am a beginner with hadoop and trying to install and run hadoop in my Ubuntu as a single node cluster. This is my JAVA_HOME in my hadoop_env.sh
# The java implementation to use.
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386/
export HADOOP_CONF_DIR=${HADOOP_CONF_DIR:-"/etc/hadoop"}
But when I run it the following errors come-
Starting namenodes on [localhost]
localhost: Error: JAVA_HOME is not set and could not be found.
localhost: Error: JAVA_HOME is not set and could not be found.
Starting secondary namenodes [0.0.0.0]
0.0.0.0: Error: JAVA_HOME is not set and could not be found.
How do I remove this error?
I debugged the code and found out that even though JAVA_HOME is set in the environment, the value is lost as ssh connections to other hosts is made inside the code, and the JAVA_HOME variable that was showing well set in start-dfs.sh became unset in hadoop-env.sh.
The solution to this problem will be to set JAVA_HOME variable in hadoop-env.sh and it should work properly.
I had the same error and solved it with Soil Jain's remark, but to make it even a bit more clear: the hadoop-env.sh uses an expression such as
export JAVA_HOME=${JAVA_HOME}
if you hard-code the path to your JVM installation it works
export JAVA_HOME=/usr/lib/jvm/java...
this resolution by environmental variable as is seems to fail. Hard-coding fixed the problem for me.
Under your HADOOP_HOME/conf directory please update the hadoop-env.sh file. It has entry to export JAVA_HOME.
Setting to appropriate JAVA_HOME in this file should solve your issue.
Are you loading hadoop_env.sh? you may be refering to hadoop-env.sh ( dash instead of underscore - that is under conf directory)
BTW, This is a very useful guide for quick installation :
http://www.michael-noll.com/tutorials/running-hadoop-on-ubuntu-linux-single-node-cluster/
First, you must set JAVA_HOME in your hadoop_env.sh . (your local JAVA_HOME in .bashrc would likely to be ignore somehow)
# The java implementation to use.
export JAVA_HOME=/usr/lib/jvm/default-java
Then, set HADOOP_CONF_DIR point to directory of your hadoop_env.sh . In ~/.bashrc, add the following line:
HADOOP_CONF_DIR="/usr/local/hadoop/etc/hadoop"
export HADOOP_CONF_DIR
Where /usr/local/hadoop/etc/hadoop is the directory contained hadoop_env.sh
I'm using hadoop 2.8.0. Even though I exported JAVA_HOME (I put it in .bashrc), I still caught this error while trying to run start-dfs.sh.
user#host:/opt/hadoop-2.8.0 $ echo $JAVA_HOME
<path_to_java>
user#host:/opt/hadoop-2.8.0 $ $JAVA_HOME/bin/java -version
java version "1.8.0_65"
...
user#host:/opt/hadoop-2.8.0 $ sbin/start-dfs.sh
...
Starting namenodes on []
localhost: Error: JAVA_HOME is not set and could not be found.
localhost: Error: JAVA_HOME is not set and could not be found.
The only way I could get it to run was to add JAVA_HOME=path_to_java to etc/hadoop/hadoop-env.sh and then source it:
:/opt/hadoop-2.8.0 $ grep JAVA_HOME etc/hadoop/hadoop-env.sh
#export JAVA_HOME=${JAVA_HOME}
export JAVA_HOME=path_to_java
user#host:/opt/hadoop-2.8.0 $ source etc/hadoop/hadoop-env.sh
Maybe that (sourcing hadoop-env.sh) was implied in the posts above. Just thought someone should say it out loud. Now it runs. I've encountered other issues (due, I suspect, to the limited resources on the server I'm using), but at least I got past this one.
Above answers should work as long as you are using default conf directory $HADOOP_HOME/conf or $HADOOP_HOME/etc/hadoop. Here are a few things you should do if you're using a different conf folder.
Copy the hadoop-env.sh file from the default conf directory to your conf folder, say /home/abc/hadoopConf.
Replace the line
#export JAVA_HOME=${JAVA_HOME}
with the following:
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
export HADOOP_CONF_DIR=/home/abc/hadoopConf
Change the values appropriately. If you have any other environment variables related to hadoop configured in your .bashrc or .profile or .bash_profile consider adding them next to the above lines.
It not know space between Program and Files: "Program Files".
So, I copy folder of jdk to C: or folder which not contains space in name of folder and assign: export JAVA_HOME=Name_Path_Copied. I see it run ok