I want to install and run Android Studio on my Windows 8 Pro 64-bit.
I can install, but when I running the app, this error appears:
Failed to load JVM DLL C:\Program Files\Java\jdk1.7.0_25\jre. If you
already have a 64-bit JDK installed, define a JAVA_HOMEvariable in
Computer > System Properties > System Settings > Enviroment Variables.
I define a JAVA_HOME on system variable 3 times with this values:
First time:
C:\Program Files\Java\jdk1.7.0_25
Second time:
C:\Program Files\Java\jdk1.7.0_25 ; C:\Program Files\Java\jdk1.7.0_25\bin
And third time:
C:\Program Files\Java\jdk1.7.0_25 ; C:\Program Files\Java\jdk1.7.0_25\bin ; C:\Program Files\Java\jdk1.7.0_25\jre
But I have same problem in 3 states.
Go to system properties then Advanced system settings
Cick bellow Enviroment variables
in system variables click New and input variable name JAVA_HOME and variable value java path, (example: C:\Program Files\Java\jdk1.8.0)
run studio64.exe instead of studio.exe, had same problem and this worked for me
I am using Windows Pro 8 too, here is my JAVA_HOME setting:
JAVA_HOME=c:\Program Files\Java\jdk1.7.0_15
What I can suggest is the following:
If android-studio installed successfully and cannot launch it,
go to your user profile folder :
cd %USERPROFILE%
delete ".AndroidStudioPreview"
open a new command line terminal:
set JAVA_HOME
make sure that the path returned is set to the proper java jdk directory.
If this does not show anything this means that your environment variable is not available.
Then launch android studio out of the command line.
If the problem persists try to install a new jdk side by side and point to the new jdk with JAVA_HOME.
Make sure that the installation folder in
C:\Program Files
or
C:\Program Files(X86)
If its in Program Files directory set the environment variable as
C:\Program Files\jdk_name
else
C:\Program Files(X86)\jdk_name
Change your most recent JDK folder name to the version the application is looking for. Example:
Go to:
C:\Program Files\Java
and rename the folder with most recent JDK version from \jdk1.7.0_XX to \jdk1.7.0_25
Good Luck.
Define a environment variable JAVA_HOME pointing to the JDK location (without BIN folder), like this:
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_101;
(Set it in system and local variable)
After that, add
%JAVA_HOME%\bin
to PATH variable (both in system and local settings)
Be sure to point to JDK installation directory, not JRE directory.
Then restart your computer.
If you install android studio x64 you should have java sdk x64 installed if not you can install it and try again
Related
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
I know this is a common problem, and I have tried several solutions and none of them work for me.
I have deleted everything and started over. Could someone try to help me to get this to work?
I have these folders:
C:\Android\adt-bundle-windows-x86_64-20140702
C:\Android\android-ndk-r8e
C:\Android\android-sdk-windows
C:\Program Files\Java\jdk1.7.0_67
C:\Program Files\Java\jdk1.8.0_05
C:\Program Files\Java\jre7
C:\Program Files\Java\jre8
When trying to run android.bat:
C:\Android\android-sdk-windows\tools>android.bat
'xcopy' is not recognized as an internal or external command,
operable program or batch file.
ERROR: SWT folder 'lib\x86_64' does not exist.
Please set ANDROID_SWT to point to the folder containing swt.jar for your platform.
Android currently support up to Java 7 (JDK 1.7). If you use JDK 1.8, it won't work.
Also, assuming you're using Java 7, set up JAVA_HOME in Environment Variables by pointing it to C:\Program Files\Java\jdk1.7.0_71 so the Android SDK Manager knows which Java version to use.
On Windows 64-bit, Environment Variables can be accessed by going to Start | Control Panel | System | Advanced System Settings | System Properties | Advance | Environment Variables option. Note: You may need to restart Windows for the changes to take effect.
CAVEAT: On Windows 8.1, if the above steps fail, then install the Android SDK from the installer_r23.0.2-windows.exe executable which can be downloaded from here. Also, ensure that you uninstall JDK 1.8 from Windows 8.1 and only use JDK 1.7 with Android SDK Manager (or 1.6 if you need it).
I think there is still a problem with your environment variable Path, could you check that there is a URL to your java 1.7 bin path? e.g. C:\Program Files (x86)\Java\jdk1.6.0_29\bin
You could also try from suggested here https://developer.appcelerator.com/question/136334/xcopy-is-not-recognized-as-an-internal-or-external-command:
Add this to your path variable:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files (x86)\Java\jdk1.6.0_29\bin
please check if the ANDROID_SWT environment variable is pointing to a correct folder (i.e. sdk\tools\lib\x86 in your adt folder).
I am trying to build my first android app using phonegap and for that i need jdk environment,node.js,ant.
And I am able to install jdk but for Apache ant I have tried many forum and tutorials for setting the path but not able to succeeded on this.
I set my varialbe like this....
Variable Name :- ANT_HOME
Variable Value:- C:\JAVA\ant\bin
Variable Name :- JAVA_HOME
Variable Value:- C:\Program Files\Java\jdk1.7.0_60\jre\bin\
But still i am getting "unalbe to locate tools.jar. Expected to find in C:\ProgramFiles\java\jre7\lib\tools.jar
BuildFile: build.xml doest not exists.
Build Failed.
PLEASE HELP ME OUT FROM THIS ANONYMOUS TROUBLES..
See HERE for Ant, jdk, tools.jar related instructions.
for Ant:
ANT_HOME set to C:\JAVA\ant and add ;%ANT_HOME%\bin to the PATH variable
for JDK:
JAVA_HOME set to "C:\Program Files\Java\jdk1.7.0_60\" (with the quotes if you have space(s) in your file path) and add ;%JAVA_HOME%\bin to your PATH variable.
close any command-prompt window(s) that were open prior to the changes above. Only command windows opened after the changes will have the updated environment variables.
JAVA_HOME should be the JDK installation directory (in your case C:\Program Files\Java\jdk1.7.0_60\. Then you add %JAVA_HOME%\bin to the path.
For java, see Update the PATH Environment Variable (Microsoft Windows).
You can follow a similar procedure to add ANT_HOME to your path. ANT_HOME should be C:\JAVA\ant and then you add %ANT_HOME%\bin to the path.
If echo %PATH% shows the correct values for both ant and java then you need to check your Cordova configuration as it appears your configuration is pointing to a Java Runtime Environment (JRE) instead of a Java Development Kit (JDK).
This can be done in 2 different ways:
1: From Command Prompt.
C:>set ANT_HOME=C:\Program Files\Ant Files\apache-ant-1.10.5
C:>set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_181
C:>set PATH=%ANT_HOME%\bin;%JAVA_HOME%\bin
C:> ant -version
Apache Ant(TM) version 1.10.5 compiled on July 10 2018
2: By setting environment variables.
Right click on This PC > Properties > Advanced system settings > Environment Variables > User variables > New > Variable name:**ANT_HOME & for **Variable value:**C:\Program Files\Ant Files\apache-ant-1.10.5 > **OK.
Now goto System variables to add bin path. System variables > double click on Path >New > C:\Program Files\Ant Files\apache-ant-1.10.5\bin >New >C:\Program Files\Java\jdk1.8.0_181\bin>OK.
Now lets check whether it is installed correctly or not.
goto Command Prompt > and type ant -version.
C:> ant -version
Apache Ant(TM) version 1.10.5 compiled on July 10 2018
That's it. Let me know if still getting any difficulties.
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
OS: Windows XP
I am using yuicompressor-2.4.2 to compress some CSS before uploading to my server.
But when I run it, the following exception appears:
Exception in thread "main" java.lang.UnsupportedClassVersionError:
com/yahoo/platform/yui/compressor/Bootstrap (Unsupported major.minor version 48.0)
So I think it's because of the JRE.
I typed in the command:
cmd: java -version
And it says:
java version "1.3.1_01"
But it should say 1.6.0_16, since I have installed the latest version.
What should I do to make Java use the latest version instead of the old one?
Set the environment variable JAVA_HOME pointing to the directory where you have jdk 1.6.0
set JAVA_HOME=your_path_to_jdk1.6
set PATH=%JAVA_HOME%/bin;.;..;%PATH%
That's from a command window. Also you can do it from "My PC > Properties > Advanced > Environment variables"
Go to the system32 directory C:\Windows\System32 and delete following 3 files
java.exe
javaw.exe
javaws.exe
Now create a JAVA_HOME environment variable with value={root path of your jdk installation} and add the path till bin folder of your jdk in the PATH environment variable.
Open a fresh command prompt and run java -version to confirm the change
If you are using windows 7/10 go to command prompt and type
where java
Delete all the symbolic link shows below other than your actual installation directory.
Even if correctly added all the environment variables still sometime you can get wrong versions especially when you have multiple version installed in your system and want to switch between them.
On Windows, the JRE installs a java executable in the Windows directory, which should be the first java in your path. This is just a wrapper that looks in the Windows Registry to find the Java home directory (should be "%SystemDrive%\Program Files\Java\jre6" for Java 6) and runs using the libraries there.
Run %SystemRoot%\system32\java -version and see what you get. If that is Java 6, you have entries in your path before %SystemRoot%\system32 (which really should be first). Either fix your %PATH% variable, or you'll have to be explicit whenever you want to run this version of Java.
If running that instance of java doesn't report Java 6, its not installed (correctly). Uninstall and try installing again.
If you are having trouble because of the PATH, it is because you or some software you installed monkeyed with it; I recommend using the default which is to have system32 first. Everything works fine if the defaults are used.
Also, %JAVA_HOME% is not used by the JRE itself at all. Some common Java applications like tomcat and ant honor the %JAVA_HOME% setting, so perhaps yuicompressor does too. But this is a de facto convention, not a standard.
after where java in Command prompt
for example
where java
C:\Program Files\Common Files\Oracle\Java\javapath
C:\Program Files\Java\jdk-11.0.10\bin\java.exe
delete C:\Program Files\Common Files\Oracle folder
then close all terminals and write java -version in the terminal. it will show the right version
worked for me
You should modify your PATH environment variable:
My PC > Right click > properties > Advanced > Environment variables
And modify "Path"
Append at the end the path to your 1.6 installation:
;C:\jdk1.6.xxx\bin
and remove the previous one if present.
Add %JAVA_HOME%/bin to your PATH environment variable where JAVA_HOME is set to your JRE6u16 directory
I had the same problem. In System Properties > Environment Variables > System Variables > PATH make sure there is no other path associated with Java. To make sure, type in and check Java paths.
where java
Re-open Command Prompt and type java -version again. I hope this helps.
first by the following command, you should be aware of .exe file which runs when you type java in the command prompt
where java
C:\Program Files\Common Files\Oracle\Java\javapath
C:\Program Files\Java\jdk-11.0.10\bin\java.exe
as you see above , cmd first reads java from
C:\Program Files\Common Files\Oracle\Java\javapath
so go to the path above and remove java files .
then it should work fine
You should check your PATH environment variable. It is possible that some application you have installed has put its version of the jre in front of yours in the path.
It looks like the older Java version is still on the system PATH environment variable (where the OS looks for commands) or JAVA_HOME (where yuicompressor may look for the java executable)
How those variables are changed depends on your operating system.