JAVA_HOME does not point to the JDK.(Spring Tool Suite) - java

JAVA_HOME does not point to the JDK.(Spring Tool Suite)
I am getting an error while running Spring Tool Suite(3.9.5.RELEASE) as
org.apache.tools.ant.BuildException: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "C:\Program Files\Java\jre1.8.0_181"
As i already set the java path in Environmental Variable-->System variables as
Variable Name : JAVA_HOME and
Variable Value : C:\Program Files\Java\jdk1.8.0_131
and in Environmental Variable-->user variables as
Variable Name : path and
Variable Value : C:\Program Files\Java\jdk1.8.0_131
and in my C:\Program Files\Java\ drive there is jdk1.8.0_131 and jre1.8.0_181.
I set the path properly to JDK, also I restarted the application too, even restarted the Computer too, still I am getting the same error again.
Is there any other solution to avoid such error?

Check your project build path if it is pointing to JRE instead of JDK.
Else Check,
The path for the tools.jar, if it is wrong? or,
Is it pointing to an older version of Java? or,
If tools.jar is missing?
If all the above options do not work try reinstalling JDK.

I installed STS in eclipse Python instead of using separate STS tool and problem got solved..Still wonder why the path shows in STS tool point to jre even after setting to JdK...but i install and run STS in eclipse and it worked properly, wasted my 2 days on this error.
Thanks for your time , learned a lot about settings from you guys

Related

"Your JAVA_HOME is invalid: C:\Program Files\Java\jdk1.8.0_301" when building ionic app

I have tried every which way to declare JAVA_HOME in my system variables, but I keep getting the following error when running 'ionic Cordova build --release android'
Failed to run "javac -version", make sure that you have a JDK version 8 installed.
You can get it from the following location:
https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Your JAVA_HOME is invalid: C:\Program Files (x86)\Java\jdk1.8.0_301
I've tried appending it with "bin", I've tried wrapping C: Program Files (x86) in double quotes, I've tried uninstalling and reinstalling java, and I always get the same error. When I run echo %JAVA_HOME% it gives me:
C:\Program Files (x86)\Java\jdk1.8.0_301
How can I figure out what's wrong?
I can see a couple of problems here. The following instructions should help you resolve the issue:
The installation path has x86 which suggests that you have installed a 32-bit version of JDK. If your OS is 64 bit (which is mostly the case), download and install the 64 bit JDK.
While installing, the installer gives you an opportunity to change the installation location. The default suggested location has space that may be problematic and therefore I recommend you change it to something like C:\jdk.
Append the path of JDK bin folder to the PATH environment variable e.g. if the path of bin folder is C:\jdk\jdk1.8.0_301\bin, append this to the PATH environment variable and also move it to the top position.
Create a new environment variable, JAVA_HOME and put C:\jdk\jdk1.8.0_301 (i.e. the path, one level above the bin folder) as the value into it.
Finally, start a new cmd window and test the command, java -version.

Trying to run Maven but JAVA_HOME not found [duplicate]

I have recently downloaded Maven and followed the instructions given on this this page. I already have ant installed on my machine.
Now, if I want to verify that Maven is installed perfectly or not it is giving me error that JAVA_HOME is not set correctly, but same works perfectly fine for ANT.
For Maven I tried :
1. open cmd
2. type mvn -version
3. Error appeared :
C:\Users\Admin>mvn -version
ERROR: JAVA_HOME is set to an invalid directory.
JAVA_HOME = "C:\Program Files\Java\jre7\bin"
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation
For ANT I tried and worked :
1. open cmd
2. type mvn -version
3. Apache Ant(TM) version 1.9.1 compiled on May 15 2013
I went to the directory to check that java.exe is actually there in that directory or not and it was there. I checked the environment variables they set fine. I restarted the system and checked again but same problem. Please let me know what am I missing.
JAVA_HOME should point to jdk directory and not to jre directory. Also JAVA_HOME should point to the home jdk directory and not to jdk/bin directory.
Assuming that you have JDK installed in your program files directory then you need to set the JAVA_HOME like this:
JAVA_HOME="C:\Program Files\Java\jdkxxx"
xxx is the jdk version
Follow this link to learn more about setting JAVA_HOME:
http://docs.oracle.com/cd/E19182-01/820-7851/inst_cli_jdk_javahome_t/index.html
Do not include bin in your JAVA_HOME env variable
Follow the instruction in here.
JAVA_HOMEshould be like this
JAVA_HOME=C:\Program Files\Java\jdk1.7.0_07
JAVA_HOME = C:\Program Files\Java\jdk(JDK version number)
Example: C:\Program Files\Java\jdk-10
And then restart you command prompt it works.
Just remember to add quotes into the path if you have a space in your path to java home.
C:\Program Files\java\javaxxx\ doesn't work
but
"C:\Program Files\java\javaxxx\" does.
The JAVA_HOME should point to the JDK home rather than the JRE home if you are going to be compiling stuff, likewise - I would try and install the JDK in a directory that doesn't include a space. Even if this is not your problem now, it can cause problems in the future!
You are pointing your JAVA_HOME to the JRE which is the Java Runtime Environment. The runtime environment doesn't have a java compiler in its bin folder.
You should download the JDK which is the Java Development Kit. Once you've installed that, you can see in your bin folder that there's a file called javac.exe. That's your compiler.
JAVA_HOME should point to jdk directory like in the image with new variable, like below
PATH should point to jdk bin like below
Run the below command in your terminal and restart it.
> set JAVA_HOME="C:\Program Files\Java\jdk-xx.xx"
xx.xx is the java version

IntelliJ - Can't start - "JAVA_HOME does not point to a valid JVM installation"

For every other StackOverflow question that's been asked about this, here, here, and here, I've followed all the steps to resolve this issue, and none have worked.
When launching IntelliJ IDEA 64-bit on my 64-bit Windows 7 machine, I encounter the following error:
The environment variable JAVA_HOME (with the value of "C:\Program Files\Java\jdk1.8.0_74")
does not point to a valid JVM installation.
However, the file path does exist:
And in my Environment Variables, I have set JAVA_HOME to that location:
I've tinkered around with putting it in my User variables instead of the System and vice-versa, and tried putting it in both. It didn't work with the Java 7 JDK I had originally, so I just downloaded the Java 8 JDK and tried it - no dice.
I also restarted my computer, and CMD can use java and javac with no problem at all:
Any help on how I could resolve this? My last resort is uninstalling and reinstalling IntelliJ, which I may have to do.
In my case, the issue was that JAVA_HOME was pointing to a path upto /bin folder (C:\Program Files (x86)\Java\jdk1.8.0_91\bin\) - while Eclipse accepts this, IntelliJ does not.
Updating to JAVA_HOME=C:\Program Files (x86)\Java\jdk1.8.0_91 resolved the issue.
The java and javac executables are using the PATH environment variable, while intelliJ is using JAVA_HOME variable. Remove the additional quotation marks in your JAVA_HOME value.
It might shows that your path to the jdk installation directory is hard coded in the PATH, rather then using %JAVA_HOME%.
The problem will almost certainly be with the quotation marks around your JAVA_HOME path. Remove those and see if it works. If not, then I would recommend only putting your JDK installations under the root and with no spaces in them. I tend to put them in C:\JDK\1.8.0_65, etc. It makes referencing them far easier and you don't have to worry about quotation marks to protect spaces like you do with "Program Files".
I faced the same issue.. My mistake was I was taking the path till /bin/ and putting ; at last.
Correct is - JAVA_HOME=C:\Program Files\Java\jdk1.8.0_92
no /bin/ no ';'
Had the same issues opening PHPSTORM from command line.
Solution was to download jdk version 8 x86(32bit). Edit settings in Environment Variables by setting JAVA_HOME path in user variables for... to C:\Program Files (x86)\Java\jdk1.8.0_221
Open a CMD window, and enter:
echo %JAVA_HOME%
Verify the result is indeed the path entered your JAVA_HOME variable,
i.e. C:\Program Files\Java\jdk1.8.0_74.
In my case, a space was slipped in, that was not visible in the
Envrironment Variables window.
My problem was adding 2 path in JAVA_HOME variable (I had added x64 jdk path with x86 jdk and my android studio needed just the x86 one. I deleted the x64 path and it has just worked :)
The problem I had seemed to be due to attempting to launch idea.exe rather than idea64.exe - when I moved to the 64 one then it worked.
Since this question appeared in my google search, and none of the aforementioned answers worked for me - here is my resolution.
What worked for me was changing \ to / in path.
So in my case it was:
C:/Program Files/Java/jdk-11.0.11/ :)
You can also change the installation of OpenJDK (if you still have the installer packages) and add the JAVA_HOME variable (you have to enable it), afterwards just click through the installation until it is finished.

Ionic failed to build for Android, JAVA_HOME invalid, failed to run java -version

I already tried to set my JAVA_HOME to C:\Program Files\Java\jdk1.8.0_73
and the path is C:\Program Files\Java\jdk1.8.0_73\bin.
The goal of what you are asking to do is to install java and let some other program find java by setting two Windows variables JAVA_HOME and path to point to the java directory and the java executable/program file directory respectively. I assume you are using windows because of some of the clues you gave. You first need to download java, get the JDK and not the JRE version. Download from herejava then set the two variables, find mycomputer icon or maybe its called this pc and right click find properties click advanced system settings, environment variables there you go, put in the variable and value for both JAVA_HOME and path
I had the same problem and had solved it.
The cause of problem changing the path when installing jdk. Changed jre path to
../jdk1.8.0/jre
the right is for example:
../java/jdk1.8.0
../java/jre8
or change nothing.
So, if you are sure that JAVA_HOME path is right, try to reinstall jdk and change nothing before complete.

system cannot get java compiler please use jdk intead of jre

When trying to deploy my application to the Google App Engine server I get the following error:
Cannot get the System Java Compiler. Please use a JDK, not a JRE.
All solutions I've seen for this involve editing an eclipse configuration file, but I'm not using eclipse. I'm executing appcfg.cmd from the dos prompt.
I have a jdk installed and my JAVA_HOME is pointing to it:
c:\program files\java\jdk1.7.0_45
Few points:
Could you check if the JAVA_HOME\bin folder is in the PATH environment variable. If not put that and make sure that it is pointing to the correct version.
Also check java -version on your machine after setting it.
I think you need to add the bin folder as the sub-directory please give it a try
c:\program files\java\jdk1.7.0_45\bin

Categories

Resources