Setting Maven environment variable - java

I been trying to set the Maven environment variable, but it's not liking it. I don't know why, I've triple checked everything and it should be working.
Here is the error I got:
ERROR: JAVA_HOME not found in your environment variable.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation
And here are my variables:
JAVA_HOME ---> C:\Program Files\Java\jdk1.6.0_26
MAVEN_HOME ----> C:\Program Files\Maven\apache-maven-3.0.5
Path ----> C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;%JAVA_HOME%\bin;%MAVEN_HOME%\bin
Sorry if my path file is a little long. Basically the important part is that I did indeed put them in right, they should both be at the very end. What else could have gone wrong?
Also to clarify a little bit, I did check that the file is indeed where I specify it to be. And I know my Java version should be right, when I do a:
javac -version
in cmd I do get the right version.

Try using M2_HOME instead of MAVEN_HOME in the path and environment variable
M2_HOME ----> C:\Program Files\Maven\apache-maven-3.0.5
and %M2_HOME%\bin in path

As you are using a jdk/maven path with space in between so try using the path in quotes such as :
"C:\Program Files\Java\jdk1.6.0_26"
Or
simply dump the java and maven in non-space directories as it avoids such problems. I generally put java in C:\Java\jdk1.6.0_26 and mavin in C:\maven\maven3.0.
Try either of the solutions and you should get lucky :-)

And please ensure to put the JAVA_HOME environment variable inside the system environment variables and not the user environment variables.
Don't forget to restart your shell after you changed environment variables.

If you are using eclipse then set VM arguments in JRE as
-Dmaven.multiModuleProjectDirectory=true

Related

Gradle says my java installation is in the wrong place, despite it finds the correct folder

I'm not sure why, but whenver I run the command ./gradlew setDecompWorkspace, I get this error:
ERROR: JAVA_HOME is set to an invalid directory: C:\Program
Files\Java\jdk1.8.0_191\bin
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
I've added the JAVA_HOME variable under my System Environment Variables as this: JAVA_HOME=C:\Program Files\Java\jdk1.8.0_191\, my system path contains this: C:\Program Files\Java\jdk1.8.0_191\bin;C:\Program Files\Java\jdk1.8.0_191
Your JAVA_HOME is pointing to the Directory C:\ProgramFiles\Java\jdk1.8.0_191\bin
Change the JAVA_HOME to C:\ProgramFiles\Java\jdk1.8.0_191 and include the
JAVA_HOME\bin in your path.
JAVA_HOME=C:\ProgramFiles\Java\jdk1.8.0_191
path= C:\ProgramFiles\Java\jdk1.8.0_191\bin;

I have installed Java 8, set environment variable and JAVA_HOME, but my system tries to find java.exe in wrong path, how do I correct it?

I have installed Java 8 and set my JAVA_HOME and JRE_HOME paths and added %JAVA_HOME% to the start of the path variable.
When I try to run simple java program I get error as
"The system cannot find the file C:\spl\java\bin\bin\java.exe".
The above path contains extra bin.
Where as environment variable and JAVA_HOME has C:\spl\java\bin\ this path.
I cannot understand from where this extra bin directory is coming.
Please help.
From where does system is taking C:\spl\java\bin\bin\ this path?
Your JAVA_HOME should point to the ...\Java\jdk1.8.. directory.
In Your path you should have %JAVA_HOME%\bin.
Some applications refer to JAVA_HOME and add \bin on their own, so you must not add \bin to your JAVA_HOME. Otherwise, you'll receive correct error saying, that C:\spl\java\bin\bin\ doesn't contain Java.exe
Solution:
Remove \bin from your JAVA_HOME
It is quite clear from your example: the system is taking %JAVA_HOME% as the "home" of your java installation, not its bin directory. So when you try to start java.exe, it looks in %JAVA_HOME%\bin. Just remove the bin part of your JAVA_HOME.

Could not find any executable java binary

please help with my problem that I'm facing since hours. I'm trying to run ElasticSearch-5.2.2 with MEAN Stack. I installed Java JDK 8 and I set the path correctly and also added this path "\Oracle\Java\javapath" still I'm getting the same error "Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME". Why it is happening can anyone help me out?
You said you "went to environment variables and added variable name: JAVA_HOME variable value: C:\Program Files\Java\jdk1.8.0_121\bin"
This is incorrect. Don't include the bin directory when you set JAVA_HOME.
Set JAVA_HOME to C:\Program Files\Java\jdk1.8.0_121
Once you are done with this, test it.
Open command prompt and type echo %java_home% and see if its printing the path you set.
Are you using Windows?
If so open your system environment variables and add a new one named JAVA_HOME and point it to your Java JDK
You can double check how to do this by referring to the thread here How to set java_home on Windows 7?
But what have you tried so far?

Java: System cannot find the file C:\ ... java.exe

I have installed Java 8 and set my JAVA_HOME and JRE_HOME paths and added %JAVA_HOME% to the start of the path variable.
I created a helloworld.java application and am able to compile it using:
javac helloworld.java
However, when I try to run:
java helloworld
I get the error:
The system cannot find the file C:\ProgramData\Oracle\Java\javapath\java.exe
How can I solve this?
1.Just go to C:\ProgramData\Oracle\Java\javapath\
2.You will find there shortcuts for java.exe,javaw.exe,javaws.exe which are pointing to a location where they actually are not existing now
3.Go to the jre location where you have installed java like C:\Program Files\Java\jre6\bin
You will find java.exe,javaw.exe,javaws.exe
Create shortcuts for these files and replace with the ones which are present in C:\ProgramData\Oracle\Java\javapath.
It works
Just set %JAVA_HOME%/bin to your path variable.
If you are blocked from modifying system variables from command line, but are able to open up an elevated command prompt, then run a command like this:
setx \M JAVA_HOME "C:\Program Files\Java\jdk1.8.0_25"
But of course, change the directory to point to your installed version of java. Note that the JAVA_HOME path does not point into the bin directory, it stops one level above bin.
I was able to solve this issue. To do so I used the advice from this answer:
Java SE Development Kit 8u25 on a 64-bit Windows 8
Set the following user environment variables (== environment variables of type user variables)
•JAVA_HOME : C:\Program Files\Java\jdk1.8.0_25
•JDK_HOME : %JAVA_HOME%
•JRE_HOME : %JAVA_HOME%\jre
•CLASSPATH : .;%JAVA_HOME%\lib;%JAVA_HOME%\jre\lib
•PATH : your-unique-entries;%JAVA_HOME%\bin
(make sure that the longish your-unique-entries does not contain any other references to another Java installation folder.)

"JAVA_HOME points to an invalid Java installation issue" with service install command in elastic search

I want to use elastic search with my PHP application.
after running service install command , I am getting fallowing error.
C:\elasticsearch-0.90.10\bin>service install
JAVA_HOME points to an invalid Java installation (no java.exe found in "C:\Progr
am Files (x86)\Java\jdk1.7.0_25\bin"). Existing...
Open up and Look into the service.bat file:
It searches for:
%JAVA_HOME%\bin\java.exe
hence your %JAVA_HOME% should not include bin in it.
A workaround if you do not have privileges to set up the environmental variables:
open the service.bat file,
a) Remove the line:
if NOT DEFINED JAVA_HOME goto err
b) Replace %JAVA_HOME% with your java jdk path, something like: C:\Program Files\Java\jdk1.7.0_51
Note: This is just a workaround which works all the time.
from your error message we can see your JAVA_HOME points to
C:\Program Files (x86)\Java\jdk1.7.0_25\bin
while it should point to
C:\Program Files (x86)\Java\jdk1.7.0_25
I think the error message is fairly descriptive , you should look in this folder
is java.exe there ? If not then your JAVA_HOME environment variable to point to the correct installation
heres a page showing how to do that
https://confluence.atlassian.com/display/DOC/Setting+the+JAVA_HOME+Variable+in+Windows
1st hit on google.
Either JAVA_HOME points to the wrong location or you don't have Java installed. Check and see if there's an install of Java in the location specified.
Also note that the JAVA_HOME variable should point to the root of the Java install not the /bin folder. This is being added by the program you're executing.
To change the JAVA_HOME variable to test further use the following in the command prompt:
set JAVA_HOME=c:\xxxx
Once you've established the correct value to use this can be permanently changed in Control Panel>>System>>Advanced System Settings>>Advanced>>Environment Variables
set JAVA_HOME=C:\Program Files (x86)\Java
Above must fix the issue, I came across the same issue while installing the elastic search.
i gave a try by giving "bin" part of path but it did not work, so i just give the top folder "java" in path, it worked.
Just to add my own experience.
i was setting JAVA_HOME using tab autocompletion.
It ends up something like "C:\Program files...:" and it didn't work saying that it cannot find the java program. I solved typing the JAVA_HOME path in the set command without using tab completion. The problem was probably related to the " in the env variable

Categories

Resources