Android SDK error - java

After running android.bat both with and without administrator powers I get the following error:
Environment Values set as:
C:\Program Files\Java\jdk1.7.0_71\bin set for JAVA_HOME, JDK_HOME, and JAVA_PATH
C:\Program Files\Java\jdk1.7.0_71\bin;%SystemRoot%\system32; set for PATH
C:\Users\elija_000\AppData\Local\Android\Sdk\tools\lib\x86_64\swt.jar set for ANDROID_SWT

You have redundant environmental variables !! only PATH and JAVA_HOME are required.. JDK_HOME, JAVA_PATH are not required.. further more if you have eclipse and ADT, open eclipse go to 'window' then select 'android sdk manager'.. see if that opens or not to test.

Try to reinstall the java
maybe it will work

Related

Persistent React Native problem: JAVA_HOME is not set

I'm trying to create a React Native app for Android on Windows 10, but every time I use react-native run-android I get the same Error: ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
I've already set up this variable via the Control Panel
And I've set up the Path variable to both the JDK and JRE
I've uninstalled and reinstalled the JDK and Android Studio, I have tried removing and adding "\bin" to both the Path and JAVA_HOME variables, and I've been browsing similar questions (including this one and this one) to no avail.
What can I do?
When I set the environment for react native, I usually use these settings.
Add the variable JAVA_HOME to the path C:\Program Files\Java\jdk1.8.0_231
And I add to the system path:
%JAVA_HOME%\bin
%ANDROID_HOME%\emulator
%ANDROID_HOME%\tools
%ANDROID_HOME%\tools\bin
%ANDROID_HOME%\platform-tools
I hope it helps.
this works for me to
Add the variable JAVA_HOME to the path C:\Program Files\Java\jdk1.8.0_231
And I add to the system path: %JAVA_HOME%\bin%ANDROID_HOME%\emulator%ANDROID_HOME%\tools%ANDROID_HOME%\tools\bin%ANDROID_HOME%\platform-tools

JAVA_HOME should point to a JDK not a JRE

I am trying to set up maven for my project and I am getting this error
"JAVA_HOME should point to a JDK not a JRE"
I know there are already similar question but it did not work. How can I point JAVA_HOME to JDK in windows. I am using IntelliJ IDEA
Control Panel -> System and Security -> System -> Advanced system settings -> Advanced -> Environment Variables -> New System Variable
I am going through the same process on Mac OSX. I installed the latest JDK, then installed Maven. Someone suggested I set the JAVA_HOME variable so I pointed it to the JDK installation folder. When running Maven mvn compile exec:java I received the same error NB: JAVA_HOME should point to a JDK not a JRE.
All I did was unset the JAVA_HOME variable and it worked.
do it thru cmd -
echo %JAVA_HOME%
set set JAVA_HOME=C:\Program Files\Java\jdk1.8.0
echo %JAVA_HOME%
I met the same problem. (Window 10 environment)
I solved it by deleting the JAVA_HOME="C:\Program Files\Java\jdk1.8.0_161\bin" in the User Variables instead of adding to the System Variables directly.
Then I test that editing JAVA_HOME="C:\Program Files\Java\jdk1.8.0_161\" worked too.
When I run "mvn -version" in command prompt window, it shows "Java home: C:\Program Files\Java\jdk1.8.0_161\jre".
In conclusion, I guess the JAVA_HOME shouldn't include bin directory.
I added JAVA_HOME path in user variable and omit the "/bin".
I tried every method given here but only this worked for me.
I have spent 3 hours for solving the error The JAVA_HOME environment variable is not defined correctly. This environment variable is needed to run this program NB: JAVA_HOME should point to a JDK not a JRE
Finally I got the solution. Please set the JAVA_HOME value by Browse Directory button/option. Try to find the jdk path. Ex: C:\Program Files\Java\jdk1.8.0_181
It will remove the semicolon issue. :D
My JAVA_HOME was set correctly but I solved this issue by running Command Prompt as Administrator
In Mac OS the hierarchy library > java > JavaVirtualMachines - (inside this folder there are different versions of jdk) select your desired version and inside jdk-version folder there is a contents folder inside contents you'll find "Home" folder
while declaring $JAVA_HOME you haVE TO GIVE THAT HOME PATH for example-
(normal shell commands)
open terminal type vi .bash_profile
(to open file name bash_profile)
press "i" to enable insert mode
give java home path as-
export JAVA_HOME=/Library/java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home
After editing press esc to exit editing mode
then :wq to quit and save
This will remove JAVA_HOME should point to a JDK not a JRE error
and also saves you from future errors
For mac OS, this worked for me... none of the above solutions
$ vim .bash_profile
export JAVA_HOME=$(/usr/libexec/java_home)
$ source .bash_profile
Be sure to use the correct path!
I mistakenly had written C:\Program Files\Java\. Changing it to C:\Program Files\Java\jdk\11.0.6\ fixed the issue.
In cmd I then checked for the version of maven with mvn -version.
Just as an addition to other answers
For macOS users, you may have a ~/.mavenrc file, and that is where mvn command looks for definition of JAVA_HOME first. So check there first and make sure the directory JAVA_HOME points to is correct in that file.
if You have
The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK not a JRE
Error
so do one thing ...type
C:>dir/x
and you will see the PROGRA~1 or May ~2
and After int Environment Variable Chang The JAVA_HOME Dir Like This
JAVA_HOME:- C:\PROGRA~1\Java\jdk1.8.0_144\
also Set In Path :-%JAVA_HOME%\bin;
And it Works
Make sure that you do NOT have a JRE path, if you have delete it.
Add JAVA_HOME in the System variable. Variable value: C:\Program Files\Java\jdk-10.0.2 (location of JDK without bin)
Add M2 in the System variable. Variable value: C:\dev\maven\apache-maven-3.5.4\bin (location of maven with bin)
Add M2_HOME in the System variable. Variable value: C:\dev\maven\apache-maven-3.5.4 (location of maven without bin)
Add %JAVA_HOME% and %M2% in Path System Variable or C:\Program Files\Java\jdk-10.0.2 and C:\dev\maven\apache-maven-3.5.4\bin --> For windows 10, just add the location. For other version, at the end of the Variable Value field add semicolon then the location Ex: ;%JAVA_HOME%;%M2%
I did not check if the addition or removal of bin changes the result but nonetheless this works for me.
In addition to sovas' response on how to add the JAVA_HOME variable, if it was working before and stopped working, ensure that the path still exists. I updated Java recently which deleted the old version, invalidating my JAVA_HOME environment variable.
This worked for me for Windows 10, Java 8_144.
If the path contains spaces, use the shortened path name. For example, C:\Progra~1\Java\jdk1.8.0_65
Under System Variables add below
JAVA_HOME = C:\Program Files\Java\jdk1.8.0_201
JDK_HOME = %JAVA_HOME%\bin
M2_HOME = C:\apache-maven-3.6.0
MAVEN_BIN = %M2_HOME%\bin
MAVEN_HOME = %M2_HOME%
Under path Add these
%M2_HOME%
%JDK_HOME%
you should only add this path to Manage Jenkins -> Global Tool Configuration -> JDK
for java 11
/usr/lib/jvm/java-11-openjdk-amd64
for java 8
/usr/lib/jvm/java-8-openjdk-amd64
And then use same in your jenkins jobs accordingly
In IntelliJ IDEA go to File>Project Structure>SDK>JDK home path.
Copy it and then go to
My Computer>Advanced Settings>Environment Variables
Change the JAVA_HOME path to what you have copied.
Then open new cmd, and try mvn -v
It worked for me !!!
Add JAVA_HOME = C:\Program Files\Java\jdk(version) in User variable, it works for me. For me, it doesn't work with bin and even if I create JAVA_HOME in system variable
just remove the semicolon at the end of JAVA_HOME variable's value.
set JAVA_HOME as C:\Program Files\Java\jdk1.8.0_171
It worked for me.
I had this issue but for Mac Os, I set the JAVA_HOME variable in the .bash_profile to be export JAVA_HOME=$(/usr/libexec/java_home) then save. After that ran source ~/.bash_profile finally mvn -version and it fixed the issue. Hope that helps
First, ensure that the Maven bin is in your Environmental Variable PATH entry.
If it is, make sure your entries aren't somehow out of order, and that JAVA_HOME is before Path in the list, or any entry that references %JAVA_HOME%. I was getting the same error when I was trying to check my maven version.
I have a few extra path variables that reference %JAVA_HOME%, or a different version of a JDK and Maven was mixed in between. I moved my Maven path entry below my %JAVA_HOME% one and now everything is working when I use Maven from cmd.
But it is Windows, so perhaps my just opening and closing the Environment Variables setting somehow made everything better.
Windows 10 Home for me:
I'm studying maven through a udemy course. First time environment variables were ok. I had on JAVA_HOME on SYSTEM VARIABLE like this:
D:\Install\Java\jdk-12.0.1;D:\Install\apache-maven-3.5.4-bin\apache-maven-3.5.4
After some days, don't know what's happened, I began to receive:
C:\Users\Franco>mvn -version
The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK not a JRE
After trying all above, I tried to delete jdk the entry on SYSTEM VARIABLES, and putting it on USER VARIABLES, so now I have:
JAVA_HOME on USER VARIABLES: D:\Install\Java\jdk-12.0.1
JAVA_HOME on SYSTEM VARIABLES: D:\Install\apache-maven-3.5.4-bin\apache-maven-3.5.4
now restarting CMD I have:
C:\Users\Franco>mvn -version
Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-17T20:33:14+02:00)
Maven home: D:\Install\apache-maven-3.5.4-bin\apache-maven-3.5.4\bin\..
Java version: 12.0.1, vendor: Oracle Corporation, runtime: D:\Install\Java\jdk-12.0.1
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
In my case the error started showing up as Java version got updated. So JAVA_HOME path became invalid.
Please check
Location referred to in JAVA_HOME exists.
If it's like my case, update the value from the old path to the new path.
(A better fix would be to set java update such that it auto upgrades the JAVA_HOME reference.)
Even after trying this solution from sovas which is accepted if it does not work
RESTART intellij / CMD prompt instead of trying on the existing opened
i was trying the command from terminal under intellij but still getting same problem.
Do reopen cmd / INTELLIJ and the variable will get reloaded. It fixed the problem for me (ofcourse after correcting the Path to JDK not jre and removing the bin

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

Android Studio - JAVA_HOME doesn't point to a valid JVM installation

Having trouble firing up android studio. Get the following message: The environment variable JAVA_HOME (with the value of ?C:\Program Files\Java\jdk1.8.0_31) does not point to a valid JVM installation. The problem is that as far as I can tell, the environment variable I set up IS pointing to a valid install.
I've tried everything from renaming it to JDK_HOME, to pointing it to all the sub directories in the jdk folder, to uninstalling and reinstalling java and android studio about 3 time. I have triple checked that I have 64 bit JAVA installed (and that my computer is 64 bit). Pretty much at the end of my rope here. Help would be appreciated big time.
Here's a screen cap of my windows, you might spot something obvious I haven't:
You can try this
Android Studio error: "Environment variable does not point to a valid JVM instalation"
this works for me.
If you start 64bit Android Studio, you have to add JAVA_HOME as
"C:\Program Files\Java\jdk..."
If 32bit
"C:\Program Files(x86)\Java\jdk..."
and dont put "\bin" end of the path.
As you told you have 64 bit system then copy this path C:\Program Files\Java\jdk1.8.0_31
Step 1 :- Create JAVA_HOME variable by clicking new and past ( C:\Program Files\Java\jdk1.8.0_31) this path.
Step 2 Then click path variable and edit then past it your path after add semicolon (;) C:\Program Files\Java\jdk1.8.0_31
I am using windows 10 so this windows look like this
Note :- If above dialog not open then
, select path variable and click on Edit…. Locate the end of the current variable value
append the path of jdk, using a semicolon And click ok
To fix it, just remove "\bin" from my JAVA_HOME variable.
NOTE: be sure to put the JAVA_HOME path variable in the System variables rather than the user variables. If the path variable is in User the Android Studio will not find the path.
If you are sure that the variable is pointing to the right place, then:
Acess "C:\Program Files\Android\Android Studio\bin"
Choice the .exe for your machine.
Faced same problem for many weeks.
What worked for me:
uninstalled all java from laptop
then installed jdk 7 64 bit,
deleted JAVA_HOME and added JDK_HOME.
To fix Android Studio - JAVA_HOME doesn't point to a valid JVM installation Problem, follow the below steps:
Step 1: Open the command window by typing ‘cmd‘ in the Start menu search box.
Step 2: Now change the directory to the Android studio installation :
cd "c:\Program Files (x86)\Android\android-studio\bin"
Step 3: Type ‘studio.bat‘ and hit enter. If the JAVA environment variables are not set properly, then you should get an error message as below.
Step 4: So, it is clear that Android studio is not able to read the JDK location. All you need to do is, set the JAVA_HOME and JDK_HOME environment variables by following the steps mentioned in this guide.
Step 5: Close the existing command window. This step is very important, as the newly set variable will not reflect otherwise.
Step 6: Re-launch the command window and type the below command to ensure that the environment variables are set properly.
echo %JAVA_HOME%
echo %JDK_HOME%
Step 7: Now change the directory to the Android studio installation.
cd "c:\Program Files (x86)\Android\android-studio\bin"
Step 8: Type ‘studio.bat‘ and hit enter. Now the Android studio will launch normally.
Based on these link : Google Android Studio is not launching?
I use Windows 8.
2 steps:
Download jdk-7u80-windows-x64.exe
1.1 It's a requirement # https://developer.android.com/sdk/index.html#Requirements
Set JAVA_HOME to C:\Program Files\Java\jdk1.7.0_80
NOTE: not in Program Files (x86)
Remember that you have to set the JAVA_HOME variable to C:\Program Files\Java\jdk1.8.0_31, just like you set the variable JDK_HOME. :)
See this post for reference:
Android Studio installation on Windows 7 fails, no JDK found
Also, you could try installing an older version of java, as the newest ones might not be compatible with your IDE. Reference: Android Studio error: "Environment variable does not point to a valid JVM installation"
Ensure JAVA_HOME is in the "System Variables" and points to the JDK short path. For example if the JDK is C:\Program Files\Java\jdk1.7.0_79 set JAVA_HOME to C:\PROGRA~1\Java\JDK17~1.0_7 .
I was getting the above error message initially upon install but it started working when I made this change, and it was not necessary to reboot.
make JAVA_HOME a system variable under environment variables and set it to C:\Program Files\Java\jdk1.8.0_31.
After that logout and login back. This should eliminate the error message that you are getting. Then launch the Android Studio.
JAVA_HOME path : C:\Program Files\Java\jdk1.8.0_102\ //Copied from PATH variable.
Remove quotes if any.
If your system is 32 bit then execute studio.exe
If your system is 64 bit then simply execute studio64.exe
It solved my issue
I tried installing all the versions of JDK and changing the user environment variable. Only the following worked. Install the same versions and you are good to go.
Android studio version is 2.1.2
Install Java jdk1.8.0_91
Add the following user environment variable JAVA_HOME C:\Program Files\Java\jdk1.8.0_91
in your system Variable ( path ) append this wilset the C:\Program Files\Java\jdk1.8.0_31
In your case you just have to do the following:
`Go to Control Panel> Advanced System Settings> Environment Variables
> System Variables> New> Variable name: JDK_HOME
Variable value: C:\Program Files\Java\jdk1.8.0_31\
and then click on android studio..It will start working.`
I am using windows 7 32-bit and this worked for me:
Added new system variable: JDK_HOME with correct location of my JDK:
C:\Program Files\Java\jdk1.8.0_151
For this issue, I download the jdk oracle version 11 on the official java website, I then set the JAVA_HOME in the environment variable to the jdk path for both the user and system. It is important that it is jdk and not type jre. Hopefully this helps. Run the Android studio 64-bit type, if does not work try the 32-bit.
I found there is some issue if you download the wrong version of 32 or 64 bit version so be careful on that.
For me it got fixed when I removed the leading and trailing double quotes in the JAVA_HOME system environment variable (Windows 7 x64):
Did NOT work: "C:\path\to\jdk\without\bin"
Did work: C:\path\to\jdk\without\bin
Note:
I do not have any spaces in the path to the JDK (custom location)!
Step 1) Download your version of jdk exe file and run it. http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Step 2) Once installation is complete, you will see the jdk directory in Java folder in Program files under C Drive
Step 3) Right click on my computer, then click on advance settings, then click on environment settings.
Step 4) add a new variable called JAVA_HOME and set its path to PATH = C:\Program Files\Java\jdk1.8.0_31\
Step 5) Run Android Studio :)
FOR JAVA RELATED INSTALLATION THIS IS THE PATH SETTING ARE MATCHED N RUNS YOUR INSTALLATIONS SUCCESSFUL.
Step 1 :- Create JAVA_HOME variable by clicking new and past ( C:\Program Files\Java\jdk1.8.0_31) this path.
Step 2 Then click path variable and edit then past it your path after add semicolon (;) C:\Program Files\Java\jdk1.8.0_31
MY COMPUTER
|
RIGHT CLICK
|
PROPERTIES
|
ADVANCED SYSTEM SETTINGS
|
ADVANCED TAB
|
ENVIRONMENT VARIABLES
|
USER VARIABLES
|
NEW
|
VARIABLE NAME = JAVA_HOME
VARIABLE VALUE = "C:\Program Files\Java\jdk1.8.0_131"
REMOVE BIN, IF YOU ADDED ALREADY...
Hi! It works for me...
We can also resolve this issue by using jdk 8
to install jdk 8 click here http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.htmli
and download jdk setup install it
to copy the path go to c drive select programme file folder then choose java
then choose jdk and you will see the version go to that folder and copy the path and right click on my computer go to properties then choose advance settings then you will see one pop pup in that you have to choose variables.and click on new tab and give the name of variable JAVA_HOME and in the path you need to past the path that you have copy for jdk 8
enter image description here
after that you have to click ok ok two times
now start your android studio error will be resolved
Delete your all user variable paths from Environments Variable, and keep only two (TEMP & TMP) variables, it will work.

Add compiler to PATH environment variable

I have already installed the JDK for java which i believe has the compiler and everything i need.
Now I installed Netbeans and it is telling me that it cannot find the compiler, and to set my environment variable.
I have had my hard drive replaced i don't know if thats why I'm having trouble
variable value is
%SystemRoot%\system32; %SystemRoot%; %SystemRoot%\System32\Wbem;
%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\
I tried to add this directly after.
;C:Program\Program Files\Java\jdk1.7.0_71\bin
as well as
;%ProgramFiles%\Java\jdk1.7.0_71\bin
It doesn't work. Please help, any suggestions .
Set the path...
Find JDK Installation Directory
First you need to know the installation path for the Java Development Kit.
Open the default installation path for the Java Development Kit
C:\Program Files\Java
There should be a subdirectory like
C:\Program Files\Java\jdk1.6.0_10
Set the JAVA_HOME Variable
Once you have the JDK installation path:
Right-click the My Computer icon on
your desktop and select Properties.
Click the Advanced tab. Click the
Environment Variables button. Under System Variables, click New.
Enter the variable name as JAVA_HOME.
Enter the variable value as the installation path for the Java Development Kit.
Click OK.
Click Apply Changes.
Restart pc
Read more here http://www.robertsindall.co.uk/blog/setting-java-home-variable-in-windows/
You have to set your JAVA_HOME to your jdk (something like that C:\Program Files\Java\jdk1.7.0_71) and add to te Path the bin folder of the jdk (someting like C:\Program Files\Java\jdk1.7.0_71\bin)
declare JAVA_HOME = C:Program\Program Files\Java\jdk1.7.0_71\
add bin in path with PATH = %PATH%;%JAVA_HOME%\bin
try javac or java

Categories

Resources