I have java jre7 installed and also jre6, but the current version that is in use is the jre7. How do I tell windows to use the jre6 instead of 7? I've seen some guides of how to do so but it seems that they related to winXP since they were dealing with the JAVA_HOME variable (which does not exist on win7).
I've tried to add the path of the bin folder of the jre6 to the PATH environment variable but it didn't work. Do you have any other ideas?
By the way - I do want my eclipse to run the jre7, so I figured out I need to add/change lines in the eclipse.ini file, what exactly do I need to do there?
Thanks in advance,
Guy
Like on other windows versions (and by the way like on linux too), you have to set the JAVA_HOME environment variable.
If this var doesn't exist yet, it simply means you have to create it.
Here's how you can set an env variable on Win7 : http://www.windows7hacker.com/index.php/2010/05/how-to-addedit-environment-variables-in-windows-7/
For Eclipse, go in the preferences, choose java/installed JREs and choose the one you want. But for most of your other java based programs, the JAVA_HOME is really the important variable (along with the PATH).
Related
Sorry about being a newbie for this issue... But I'd really like to know the scope and when to run the SetEnv.Cmd under the Bin folder of the Windows SDK.
Since I only ran it in a command prompt, isn't the environment variable settings I did their only local to that session? Do I need to re-run it after I close that session? I tried and it seems to be that I don't need to, but... Why is this all done in a local session?
Sorry about the naive question,
Shawn
The SDK build tools require environment variables to be configured for the include path, library path, exe path, etc. Each version of the SDK has its own include files, etc. so each version requires different values for the variables. Hence the variables cannot be configured as permanent variables for the user (or system).
Instead, each SDK version provides the SetEnv.cmd batch file to configure the environment for that version of the SDK, and the variables are local to the current command-prompt.
When you install the SDK you get a shortcut created in the Start Menu that opens a command-prompt and runs SetEnv.cmd for you. For example, on my computer I have "Windows SDK 7.1 Command Prompt".
I just download Android Studio for Windows 7, the wizard went ok up to the end but now when I click on the shortcut or on the .exe to start the program nothing happens, no error, no new window, it's seems like it is doing nothing. Do you have any suggestion?
It's a bug of Android Studio 0.1v
You should add JAVA_HOME to the system environment variables.
http://tools.android.com/knownissues#as0.1
Open Start menu > computer > System Properties > Advanced System
Properties
In the Advanced tab > Environment Variables, add new system
variable JAVA_HOME that points to your JDK folder, for example C:\Program Files\Java\jdk1.7.0_21
Install latest Java Development Kit.
Set path in system variables for Java (ie *C:\Program Files\Java\jdk1.7.0_21\bin*)
Set JDK_HOME system variable (ie *C:\Program Files\Java\jdk1.7.0_21*)
If not working, set JAVA_HOME in system variable too (ie *C:\Program Files\Java\jdk1.7.0_21*)
If not working, check if you don't have spaces at the ends of the lines in system variables (PATH, JDK_HOME, JAVA_HOME)
You don't have to restart computer after changing system variables, just reload command prompt (if you are using it).
If it still not working, you probably have java.exe in C:/Windows/System32/. Rename it, restart command prompt and type java -version to check if you are using correct version of JDK.
I've posted tutorial how to fix Android Studio with screenshots on my blog.
I have had a similar problem with Android Studio 1.0 in windows 7 x64. When I ran studio64.exe it flashed the android studio logo and it disappeared immediately. Also I tried
studio64.exe > error.log
to figure out possible errors. JAVA_HOME=C:\Program Files\Java\jre1.8.0_25 environment variable was correctly setted.
Finally I decided to uninstall all Java versions (I had a mess of different java versions installed), both jdk and jre and reinstalled last version jdk 1.8.0_25. My problem was solved.
Regards,
Sometimes it might get stuck in memory. Open task manager, terminate android stuido. Open it up again.
If you install new the version of android studio.
It requires new jdk 1.8.
Just install the latest jdk 1.8 and android studio will work without the need to manually edit any environment variables.
You have to add a new system variable named ANDROID_STUDIO_JDK or JDK_HOME with the path to your JDK install folder, such as C:\Program Files\Java\jdk1.7.0_21\
I had the same exact problem and did try to do every thing manually nothing worked except for this command when I finished it finally launched. Open CMD with administrator if possible then put the following command:
set path="$PATH":C:\Program Files\Java\jdk1.7.0_21\bin
Then just try to launch it should work.
This is the only thing that worked for me.
Make sure you have Java 1.8 (JDK) or higher and update java_home and path to this version.
I did every tips but i checked AS requirements and updated jdk do 1.8.xx
It's possible there is a problem with your username (and name of the user folder). It shouldn't contain non-latin letters.
I had solved my problem (no response to an attempt to run Android studio) when I tried running the application as another Windows user (with name that consists of English letters only)
I got the same problem, but with no error message.
I found a studio.bat file and dig in it. There, I found some tips:
I found out thet the variable suggested in a previous post is incorrect.
ANDROID_STUDIO_JDK is no good.
STUDIO_JDK is the one.
Also, just to make the things/solution worst to corner,
I've uninstalled jre and jdk then reinstall jdk only.
The setup variables are like this:
JAVA_HOME is now pointing to C:\Program Files\Java\jdk1.8.0_172\bin
JDK_HOME is pointing to C:\Program Files\Java\jdk1.8.0_172
STUDIO_JDK is pointing to C:\Program Files\Java\jdk1.8.0_172
It's a mess but it's working...
Is it because I uninstalled/reinstalled java sdk and jre? or just the env. variables? who knows :)
Specs:
i5 with 4gig ram
win 10 32bit
In addition to following the steps pointed out by Tigris I also had to run the Android Studio with Administrative rights. Not sure why but I just made it in a few minutes ago.
Follow the steps here: http://tools.android.com/knownissues#as0.1
Run Android Studio as Admin
There is Another Issue
http://tools.android.com/knownissues
open a "cmd.exe" (command prompt), cd to the android-studio\bin folder and run "studio.bat". You will most likely see an error: for example b/55267 is about the option -XX:+UseCodeCacheFlushing not being recognized. Report the error, remove the line from the studio.exe.vmoptions or studio64.exe.vmoptions and it should now work.
There could be a process still running in the background that would need to be killed in the task manager. The name of the process is studio64.exe (at least that's the name on my machine). Could be because I am running a 64-bit OS. After killing this process, try to run Android Studio again, and it should work.
If your path and/or environment variables are not pointing to the correct JDK, things won't work properly.
A rock solid solution, especially if you must have multiple JDKs installed (e.g. Java 6/7/8) is to create a batch file to launch Android Studio.
Create a new file called studio.bat and place this somewhere outside the Android Studio installation, e.g.
c:\mydevstuff\launchers\studio.bat
(if you put the batch file anywhere in the android-studio folder, then you'll have problems when updating Android Studio).
Put the following code in the new batch file:
#echo off
REM Can make paths relative to SCRIPT_PATH if necessary
set SCRIPT_PATH=%~dp0
set ANDROID_STUDIO_JDK=<JDK Path>
set JAVA_HOME=<JDK Path>
set PATH=<JDK Path>\bin;%PATH%
cd <android-studio Install Path>\bin
start studio64.exe
Replace studio64.exe with studio.exe if you need the 32-bit version.
Replace
<JDK Path>
with the path to your JDK, e.g.
C:\Program Files\Java\jdk1.7.0_25
Replace
<android-studio Install Path>
with the path to your Android Studio installation, e.g.
C:\Program Files\Android\android-studio
Now you can just run the batch file to start Android Studio.
Additional:
If you want to pin to the Taskbar, then create a shortcut to the batch file and then change it's target to:
cmd.exe /c "<path to bat>\studio.bat"
Then pin this shortcut to the Taskbar by drag-and-drop.
You can also set it's icon from the original Android Studio studio.exe file.
I ran into this problem and these steps fixed it.
Remove ALL older JRE / JDK versions
Set values for JDK_HOME & JAVA_HOME to path of JDK install
if you use android studio version 2.3.3 you should have JDK with version 1.8 in the system environment values ,
to add it
click on Computer (in windows 7)
System properties
Advanced system settings (at the right)
Advanced (tab)
environment variables button
and edit the value of name JAVA_HOME to the file which contains jdk 1.8
if you don't have this variable make a new one
I have started on a project that specifically says that use 1.6 JDK to prevent form test failings.
I came across a peculiar behavior while I tried to change JDK from 1.7 to 1.6.
Even though I changed environment variables form 1.7 to 1.6 JDK version, When I run java.exe -version or java -version in cmd, it still gives the earlier version. But when I run javac -version it gives the 1.6 version.
What I did so far was,
In User Environment variables,
classpath to C:\Program Files\Java\jdk1.6.0_43(JDK installation path)
Added java_home variable and changes path to C:\Program Files\Java\jdk1.6.0_43(JDK installation path)
Changed path to C:\Program Files\Java\jdk1.6.0_43\bin(Java bin)
In system Environment variables,
Added C:\Program Files\Java\jdk1.6.0_43\bin to CLASSPATH
Created JAVA_HOME Variable and added C:\Program Files\Java\jdk1.6.0_43\bin
There was a variable that is related to Java, called QLJAVA and path was set to C:\Program Files (x86)\Java\jre7\lib\ext\QTJava.zip and I removed that variable as well.
Before I edited the CLASSPATH this is the same path that was there
My issues,
Why it selects 1.7 when used java -version, and why gives different result when ran javac -version. or is there something wrong with what I already have done?
What is the QLJAVA variable and what is the use of it and how did
end up in system variables.?
Why to change to 1.6 is not there any backword compatibility.?
Here are some of the guidelines when setting up environment variables for java.
JAVA_HOME should point to the java installation path
PATH should include %JAVA_HOME%/bin
I usually setup different java version as different environment variables and switch them up by changing JAVA_HOME
eg.
JAVA_6=c:\jdk6
JAVA_7=c:\jdk7
JAVA_HOME=%JAVA_6% (or JAVA_HOME=%JAVA_7%)
PATH=%JAVA_HOME%\bin;%PATH%
Also, some other entries in the path may point to a different version of Java so I usually add the %JAVA_HOME%\bin entry first.
Also, when making changes to environment variables, you should close and open a new cmd instance to have the environment variables reloaded.
Lastly, having spaces on your paths can have an effect. You might need to add quotes to them or use the old variable convention of DOS. eg. PROGRA~1 instead of Program Files.
To answer your issues:
your PATH environment variable points to different paths for java and javac. Just set the %JAVA_HOME%\bin as the first entry to the PATH variable and it should pick up the right version of JAVA you want.
As for QTJAVA, I haven't encountered it yet so I can't give a concrete answer. As for how it got there, well, some Software/Programs modify the environment variables when you install them so they got there that way.
It should be backward compatible or tries to be. I haven't seen the code nor have really tried JDK 7 long enough but according to the issue on the link you gave (https://tickets.openmrs.org/browse/TRUNK-3142), it looks like a JDK 7 issue.
Hope this helps.
The loader java.exe is normally placed in the Windows\System32 directory, though there are also copies in the JDK. The compiler javac.exe is always in the JDK. This is the root of what you're seeing.
There's an excellent chance that a copy java.exe appears in a folder that's earlier in your path than Windows\System32\java.exe.
It's also possible installation of v1.6 is failing to overwrite the old java.exe because you don't have enough permission to write in Windows\System32, though an error should be provided in this case.
The best way I know to figure out what is happening is to install a which.exe command, which you can find in Cygwin or MinGW. When you say which java.exe, you'll see the path to the java.exe v1.7 that is causing the problem. Adjust your path, delete, or rename the file.
Is there a way to prevent that the Java installation routine (e.g. jdk-7u1-windows-i586.exe) copies java.exe into C:\Windows\system32 directory?
I have to install my software on a client's laptop and I don't want to break other Java applications which are already installed on the machine. In other words I want to install a private JRE which is only used by my software.
By now, I copied an already installed JRE from my computer to the client's machine.
I discovered yesterday that there is a problem with Java versions on Windows, as you know keeping java up to date these days is critical, especially the JRE used by Internet explorer located in the Windows system32 or syswow64 folder.
You can perform a search for java in your C: drive and look at the various executable files it finds to determine if the situation applies on a specific system.
After doing some research I find that when the Java updater runs, it only updates the files installed in the JAVA home , usually located on the program files, but it does NOT update the files located in the windows system folder. As a result and since the system folder is in the default system PATH , the usage of Internet Explorer continues to use an old version of the JAVA files ( java.exe , javaw.exe , javaws.exe )
The solution is to uninstall java using the control panel uninstall programs feature, download most recent version and install again.
Cheers!
Fernando
I recently upgraded to java 8 and discovered this problem as the java version under system32 was still java 7. It stops you even running version as it complains about the registry keys
U:\>java -version
Error: Registry key 'Software\JavaSoft\Java Runtime Environment'\CurrentVersion'
has value '1.8', but '1.7' is required.
Error: could not find java.dll
Error: Could not find Java SE Runtime Environment.
Doing the following pointed me to the culprit:
U:\>where java
C:\Windows\System32\java.exe
C:\Program Files\Java\jdk1.8.0_45\bin\java.exe
I 'solved' this problem by just deleting the java under system32! I'm unsure of what consequences this will have.
You can just provide the JRE you want to use on your software and:
Set the JAVA_HOME variable before you run your application
Point to the correct java.exe file (e.g. ..\jre1.5.0_22\bin\java <your_java_main>)
This can be done in a *.bat file for example.
After running the *.bat file you created, all other java version will be ignored and it won't matter which versions are, or will be, installed on that pc.
I found the newest JDK still doesn't write correct code against registry.
The issue is if a computer doesn't have JRE, JDK doesn't register JRE in registry correctly.
For those install JDK 1.7u72 Just add Software\JavaSoft\Java Runtime Environment as the error message indicate. And add a string entry of CurrentVersion with value 1.7.
And then add Software\JavaSoft\Java Runtime Environment\1.7 and put a JavaHome string entry with value "C:\Program Files\Java\jre7". And JRE will function correctly.
Blame Oracle, if you use Registry, then write correct code, otherwise don't use the Registry!
All you have to do is go to Control Panel -> Programs Uninstall a program. Uninstall the old java updates and keep the newest java update and java development kit update. Your newest java update and java development kit update should have the same number.
Windows 10 Solution
Check Java Version in Console (CMD) with java -version
Check in Console (CMD) with where java, which Java Path's are enlisted.
If it you shows you "C:\Windows\System32" in its output, you will have a problem to get to your %JAVA_HOME%, where your wanted Java version resides.
Meaning, you need to get rid of "java.exe" in "C:\Windows\System32".
Just uninstall the JRE in the Software ("Programs and Features")
Hint: Keep in mind, do NOT the JDK, here in my case "Java SE Development Kit 8 Update (64-bit)"), but the JRE.
One way I would try would be to create a write-only empty file with the name java.exe into the System32 folder.
I'm having a problem getting my android dev environment setup in Windows 7. I follow the instructions here, as well as several environment sublinks. I am using Eclipse with the Android plugin. I have installed the Java JDK several times, in various locations (jdk-6u20-windows-i586.exe) - but I am obviously missing something.
Every time I run "android create avd --target 2 --name my_avd" I get an error:
C:\Users\andrew>android create avd --target 2 --name my_avd
WARNING: Java not found in your path.
Checking it it's installed in C:\Program Files\Java instead.
ERROR: No suitable Java found. In order to properly use the Android Developer
Tools, you need a suitable version of Java installed on your system. We
recommend that you install the JDK version of JavaSE, available here:
http://java.sun.com/javase/downloads/
You can find the complete Android SDK requirements here:
http://developer.android.com/sdk/requirements.html
This error message is the reason for me installing the JDK several times over. First I tried installing to a location on my e: drive. I then moved it to the default loc (program files (x86)\java\jdk.6.something. I also tried forcing it to go into the program files\ path, but it still automatically installs into the (x86) path. I have added the install path to my path environment variable every single time, yet I still continue to get this error. My suspicion is that windows 7 and the android tools are not playing together well in terms of finding the JDK, but who knows, it may be something entirely different. If you have seen this error before, I would appreciate a hint.
I had this same problem, after accidentally installed the 32-bit version of Java SDK. I uninstalled it and installed the 64-bit version (since I'm using Windows 7 64). The Android SDK setup never found Java correctly, even after I added it to my PATH variable!
After a bit of digging around, I discovered a java.exe floating around in my system32 folder, which in the order of the PATH variable came before my SDK path. After whacking the java.exe in my system32 folder, the Android Setup ran just fine!
Hope this helps.
The android command is just a Windows Batch file which in turn uses the batch file tools\lib\find_java.bat to find Java.
Having a look at the source, it does the following:
Looks to see if java.exe is on your PATH.
Looks for java.exe in somewhere under %ProgramFiles%
Your problem arises because you're using the a 64-bit version of Windows. This means %ProgramFiles% is C:\Program Files but Java is installed in C:\Program Files (x86) as it's a 32-bit application, meaning find_java.bat doesn't find it.
So to fix this you'll need to add the directory containing java.exe to your PATH environment variable.
You'll need to the add the directory containing java.exe - something like C:\Program Files (x86)\Java\jdk6\bin - on to the end of PATH with a semicolon in front of it to separate it from the previous entry.
This question on superuser.com covers maintaining Environment Variables in Windows 7.
It is really hell with JDK detection...
My params: Win 7 x64 + JDK x64 (JDK path (c:\Program Files\Java\jre7\bin)
Was googling and playing around with env variables may be 1 hour - no way.
Finally come with such solution
Manually edit android-sdk-windows\tools\lib\find_java.bat by hardcoding the path to java.exe
set java_exe=c:\Progra~1\Java\jre7\bin\java.exe
if not defined java_exe goto :CheckFailed
:SearchJavaW
set javaw_exe=c:\Progra~1\Java\jre7\bin\javaw.exe
if not exist %javaw_exe% set javaw_exe=%java_exe%
goto :EOF
Thats works for me.
In the SDK tools folder go to libs and edit find_java.bat. It can usually be found in C:\Program Files (x86)\Android\android-sdk-windows\tools\lib.
Change all instances of %PROGRAMFILES% to %PROGRAMFILES(X86)%.
I did this and the error went away.
Find android-sdk-windows\tools\lib\find_java.bat and add something like the following:
set java_exe=
call :TestJavaDir "%JAVA_HOME%"
if defined java_exe goto :EOF
What worked for me was this:
add a path to your java/bin directory to the system Path variable. Do NOT include java.exe.
Steps on Win 7 64bit:
Click Windows Button
Right Click on Computer
Select Properties from the Context Menu
Click Advanced System Settings on the top left section
Click the Environment Variables... button at the bottom of the properties dialog
On the bottom list (System variables) find the "Path" variable
Click the Edit button
Go to the end of the textbox and type something like c:\program
files\java\jdk1.6.0_26\bin (make sure it matches the name of your
java directory!)
Click OK
Click OK
Click OK
Try it out!
hth,
\ ^ / i l l
I put rem statement in android.bat after the call command and hardcode the path of \bin\java.exe:
rem Check we have a valid Java.exe in the path.
set java_exe=<..>\jdk1.6.0_31\bin\java.exe
rem call lib\find_java.bat
if not defined java_exe goto :EOF
Same for setting other variable javaw_exe thus:
set javaw_exe=<..>\jre1.6.0_31\bin\javaw.exe
if not exist %javaw_exe% set javaw_exe=%java_exe%
goto :EOF
C:\Windows\SysWOW64
1down vote
I also had this same problem
-> accidentally installed the 32-bit version of Java SDK -> uninstalled -> installed the 64-bit version (Windows 7 64) -> -> the Android SDK setup never found Java correctly!
I discovered a java.exe floating around in C:\Windows\SysWOW64 folder.
After renaming this java.exe to javaX.exe, the Android Setup ran just fine!