Java default version doesnt reflect after PATH change - java

I am running currently on Java 1.7.0_17 64bit version and I want to launch an app using Java 32 bit version.
I updated PATH variable to point to (C:\Program Files (x86)\Java\jre7\bin) Java 32 bit version. Then did a java -version it still shows the 64bit version.
I gave up and tried to do a java -d32 -jar abc.jar and then it gives me an
java -d32
Error: This Java instance does not support a 32-bit JVM.
Please install the desired version.
Please let me know how can the system refresh the latest Java settings done in the PATH variable.

There is probably a java.exe in your C:\WINDOWS\System32\ folder leftover from the previous installation. Replace it with the one in C:\Program Files (x86)\Java\jre7\bin.

Related

Why am I not able to get javac -version?

i have C:\Program Files\Java\jre1.8.0_102 and C:\Program Files\Java\jre7
and C:\jdk1.8.0_121 and in command prompt , java -version giving java version 1.8.0_102 that is fine. but when I type javac -version , it giving javac.exe not compatible with your windows. But no problem in other systems with same jdk and windows. please do help
javac.exe not compatible with your windows
Sounds like you've downloaded 64 bit JDK into C:\ but you're running 32bit Windows
The JRE does not contain javac, therefore the JDK is the problem
After you get a good version of Java, you'll need to fix your PATH variables
32 bit Windows on which a 32 bit JRE was already installed. You now tried to install a 64 bit JDK on it as well, which doesn't work.
The 32 bit JRE is still there, and as some installers will put java.exe and some others in your Windows installation (windows/system32 for example) they will get picked up instead of the JRE/JDK you just installed, even if you added that one to the system path as well.
That's why you're still seeing a correct response from java -version but not from javac -version, as javac.exe isn't copied there.
Remove the java*.exe from your windows installation, install a 32 bit JDK, set your JAVA_HOME correctly, and add %JAVA_HOME%\bin to your system path.
And oh, best not install a JDK to a place with spaces in the path, some versions don't like that.
Find out you set your environment variable correctly.
set JAVA_HOME=C:\jdk1.8.0_121
and entry to path -> %JAVA_HOME%\bin

Eclipse - how to disable update dynamic java source working set [duplicate]

I am trying to get my first taste of Android development using Eclipse. I ran into this problem when trying to run Eclipse, having installed version 4.2 only minutes ago.
After first trying to start Eclipse without any parameters to specify the Java VM, I got an error message saying it couldn't find a Java VM called javaw.exe inside the Eclipse folder, so I found where Java was installed and specified that location as the parameter in the shortcut's target. Now I get a different error, Java was started but returned exit code=13.
Similar questions seem to indicate that it's a 32-bit/64-bit conflict, but I'm 99% positive that I downloaded 64-bit versions of both Eclipse and Java (RE 7u5), which I chose because I have 64-bit Windows 7.
If anyone knows how to confirm that my Eclipse and Java are 64-bit,
that'd be appreciated.
If you think my problem is a different one, please help!
Please speak as plainly as you can, as I am totally new to Eclipse
and Java.
Shortcut Target: "C:\Program Files\Eclipse-SDK-4.2-win32-x86_64\eclipse\eclipse.exe" -vm "C:\Program Files (x86)\Java\jre7\bin\javaw.exe"
Full error code...:
Java was started but returned exit code=13
C:\Program Files (x86)\Java\jre7\bin\javaw.exe
-Xms40m
-Xmx512m
-XX:MaxPermSize=256m
-jar C:\Program Files\Eclipse-SDK-4.2-win32-x86_64\eclipse\\plugins/org.eclipse.equinox.launcher_1.30v20120522-1813.jar
-os win32
-ws win32
-arch x86_64
-showsplash C:\Program Files\Eclipse-SDK-4.2-win32-x86_64\eclipse\\plugins\org.eclipse.platform_4.2.0.v201206081400\splash.bmp
-launcher C:\Program Files\Eclipse-SDK-4.2-win32-x86_64\eclipse\eclipse.exe
-name Eclipse
--launcher.library C:\Program Files\Eclipse-SDK-4.2-win32-x86_64\eclipse\\plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v201205221813\eclipse_1503.dll
-startup C:\Program Files\Eclipse-SDK-4.2-win32-x86_64\eclipse\\plugins/org.eclipse.equinox.launcher_1.30v20120522-1813.jar
--launcher.overrideVmargs
-exitdata 1e30_5c
-vm C:\Program Files (x86)\Java\jre7\bin\javaw.exe
-vmargs
-Xms40m
-Xmx512m
-XX:MaxPermSize=256m
-jar C:\Program Files\Eclipse-SDK-4.2-win32-x86_64\eclipse\\plugins/org.eclipse.equinox.launcher_1.30v20120522-1813.jar
Your version of Eclipse is 64-bit, based on the paths and filenames.
However, the version of Java that it's picking up is 32-bit, as indicated by where it is coming from, on this line:
-vm C:\Program Files (x86)\Java\jre7\bin\javaw.exe
Program Files (x86) is the folder where 64-bit Windows places 32-bit programs.
Program Files is the folder where 64-bit Windows places 64-bit programs.
This can happen when a system has more than one JVM installed, as is often the case on Windows 64-bit (for example, the JRE download page uses the bit-ness of the browser to determine what bit-ness download to offer you, and many people use(d) 32-bit browsers even though they run 64-bit Windows).
The best way to fix this, assuming you do in fact have 64-bit JRE or JDK on your system, is to specify in eclipse.ini exactly which JVM you want it to use. The instructions are detailed in the Eclipse wiki page, but basically you have to specify the -vm option in the ini file - make sure to read the wiki page carefully as the format is very specific.
Specifying the JVM path in eclipse.ini is strongly recommended because doing so isolates Eclipse from any potential changes to your system PATH that some program installers might make (I'm talking to you, Oracle!).
Another option would be to download and use 32-bit Eclipse instead of 64-bit, but it's still strongly recommended to specify the path to the JVM in eclipse.ini.
Left for historical reference:
To check your version of Java, run
java -version
in a console (command prompt). On Windows 7 with 64-bit Java 6 I get:
java version "1.6.0_27"
Java(TM) SE Runtime Environment (build 1.6.0_27-b07)
Java HotSpot(TM) 64-Bit Server VM (build 20.2-b06, mixed mode)
Note the 3rd line, which shows that this is a 64-bit version.
On a 32-bit version you'll get something like:
Java HotSpot(TM) Client VM (build 20.1-b02, mixed mode, sharing)
If you are on a 64-bit machine, then you can install the 64-bit JDK and uninstall the 32-bit one. For instance on Windows 10, just go to Settings and under Apps, you will find Java. Click on it and you will find all the different versions. Now you can select which one to uninstall.
I got this error and found that my PATH variable (on Windows) was probably changed. First in my PATH was this entry:
C:\ProgramData\Oracle\Java\javapath
...and Eclipse ran "C:\ProgramData\Oracle\Java\javapath\javaw" - which gave the error. I suspect that this is something that came along with an installation of Java 8.
I have several Java versions installed (6,7 and 8), so I removed that entry from the PATH and tried to restart Eclipse again, which worked fine.
If it's doesn't work for you, you'll need to upgrade your JDK (to the Java versions - 8 in this case).
Instructions on how to edit PATH variable
There are working combinations of OS, JDK and Eclipse bitness. In my case, I was using a 64-bit JDK with a 32-bit Eclipse on a 64-bit OS. After downgrading the JDK to 32-bit, Eclipse started working.
Use one of the following combinations.
32-bit OS, 32-bit JDK, 32-bit Eclipse (32-bit only)
64-bit OS, 32-bit JDK, 32-bit Eclipse
64-bit OS, 64-bit JDK, 64-bit Eclipse (64-bit only)
If you have recently installed Java 8 and uninstalled Java 7, install JDK 8 and retry.
For me the solution was to go into (on Windows 8.1):
System > Advanced system setting > Environment Variables
Under 'System variables' in the 'Path' variable there was the following first:
C:\ProgramData\Oracle\Java\javapath;
I removed this and Eclipse worked again!
I had the same issue, Java was started but returned exit code=13.
My solution was to create an environment variable to Windows properties variable name = PATH variable value = C:\Program Files\Java\jdk1.7.0_02\bin, not to C:\Program Files (x86)\Java\jre7\bin.
Next I added a line to file eclipse.ini → C:\Program Files\Java\jdk1.7.0_02\bin\javaw.exe.
That worked for me.
The issue was fixed by doing the following steps.
Eclipse finds the JAVA executables from
'C:\ProgramData\Oracle\Java\javapath'
The folder structure will contain shortcuts to the below executables,
i. java.exe
ii. javaw.exe
iii. javaws.exe
For me the executable paths were pointing to my Program Files(x86) (home for 32 bit applications) folder location
I corrected it to Program Files (which homes 64-bit applications) and the issue got resolved
Please find the screenshot for the same.
Adding vm argument to .ini file worked for me
-vm
C:\Program Files\Java\jdk1.7.0_65\bin\javaw.exe
Adding more details to this
for sts 3.9.18 release I was getting error Java was started but returned exit code=13 and for latest release same
issue just the returned exit code was 14. This was due to default java chosed was of 32 bit and this version of sts/eclipes is for 64 bits. resolved this by setting 64 bits version of java in STS.ini file as
-vm
C:\Progra~1\Java\jdk1.8.0_131\bin\javaw.exe
This is before vmargs parameters in the file.
The strangest fix ever. Look at your Eclipse path, and make sure you do not have strange characters (like !, #, and #). It worked for me.
Locate eclipse.ini:
Often at C:\Users\xxx\eclipse\jee-neon\eclipse, add
-vm
C:\Program Files (x86)\Java\jre7\bin\javaw.exe
after
--launcher.appendVmargs
I uninstalled Java update 25, and the issue was solved.
A clean reinstall of the Java JDK did the trick in my case. I am running Eclipse 4.4 (Luna) like a charm now.
You have to go to the folder where eclipse is installed and then you have to change the eclipse.ini file.
You have to add
-vm
C:\Program Files\Java\jdk1.8.0_202\bin\javaw.exe
Your eclipse.ini file will look like the below screenshot
It turned out I only had the 32-bit Java runtime installed.
C:\Program Files (x86)\Java\jre1.8.0_45\
All Eclipse really wanted was for me to install the 64-bit Java runtime. <= SOLVED
Java SE Runtime Environment 8u45 jdk-8u45-windows-x64.exe
http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html
Confirm your installation by checking you now have this folder
C:\Program Files\Java\jre1.8.0_45\
The solution is simple: Put the "eclipse" folder on "C:/Program Files". If it does not work, put it in "C:/Program Files (x86)".
I had this message when I had forgot to install the JDK.
The best answer here is too long. I cannot comment so I added my answer.
Go here:
http://www.oracle.com/technetwork/java/javase/downloads/index.html
Download the latest SDK (of course for x64 if your computer is x64)
Install it
Now the party is finished, and it's time to work with Eclipse ;)
I had the same problem. I was using Windows 8 with a 64-bit OS. I just changed the path to Program Files (x86) and then it started work. I put this line in the eclipse.ini file:
-vm
C:\Program Files (x86)\Java\jre7\bin\javaw.exe
Make sure you don't have special characters (%, $, #, etc.) at Eclipse path.
If you install a 64-bit Eclipse version on a PC with a 32-bit JRE this is guaranteed to occur.
So the solution is quite straightforward: You need to synchronise them by updating either one. This shall happen when downloading Oracle Fusion middleware and Eclipse expects a 32-bit environment while your JRE is 64-bit and your JAVA home is pointing to a 64-bit JDK.
Under system environment variables, make sure "C:\ProgramData\Oracle\Java\javapath" is removed.
Under system environment variables, make sure "C:\Program Files\Java\jdk1.8.0_131\bin" is added.
I had this issue. I installed Java 8 update 25 via Chrome, and therafter attempting to start Eclipse gave the mentioned error.
Uninstalled that update, and Eclipse works again.
I tried some of the solutions, but not worked for me.
Finally, I found another way, ...
Go to Environment Variables → System Variables
Set C:\Program Files\Java\jdk1.7.0_02\bin\javaw.exe to the path in the system variables.
Try it. It worked for me...
I tried the following solution:
I created a shortcut of javaw.exe from path C:\Program Files\Java\jdk1.7.0_71\bin and pasted it into the path C:\ProgramData\Oracle\Java\javapath.
After that, I launched Eclipse, and it worked for me.
I also encountered the same issue. It turned out that the environment variable Path was pointing to an incorrect Java version.
Please check the environment variable and point it to the correct Java. For example:
C:\Program Files (x86)\Java\jdk1.6.0_17\bin
To check the environment variable, go to:
Computer → properties → Advanced system settings → Advanced -> Environment variables
I have just solved the same issue upon setting up my Windows 8.1 PC. Exactly like #George Papatheodorou mentioned above (sorry I cannot add a comment), Eclipse and JRE must be both 64 bit or 32 bit.
However, it seems for Windows 8/8.1 environment, you are going to get 32-bit JRE by default (and I do not know where to change that default for the download), as explained here: http://java.com/en/download/faq/win8_faq.xml
I was using 64-bit Eclipse so there was a discrepancy. I then installed 32-bit Eclipse and everything works fine this time.
So before bothering changing any environment variables, check your JRE and Eclipse version.
Of course you can use 64-bit JRE with 64-bit Eclipse. Just make sure they match because Windows 8.1 will give you 32-bit by default.
I had a similar error after installing Java 8 on my Windows 7 system, 64 bit system.
Changing environment variables, etc. did not help. So I tried to remove the Java Update 8, but that too did not help. Downloading and installing the 64-bit version of Java 8 SDK fixed my problem. I hope this helps.
I had the same issue after I upgraded my JDK from 1.7 to 1.8. I'm using Eclipse 4.4 (Luna). The error is gone after I degrade JDK to 1.7.
Please check whether you have set two JAVA paths in the Environment Variable section. If you already installed two versions of the JDK, it might be, then double check you have put PATH for Java like below.
PATH --> C:\ProgramData\Oracle\Java\javapath
and also
JAVA_HOME ---> C:\Program Files\Java\jdk1.7.0_02\bin
If both are there, then this sort of error may occur.
If it's OK, then check in the ".ini" file the below area is OK or not.
Open ".ini" file and check
-VM path is C:\Program Files\Java\jdk1.7.0_79\bin\
If not, please set it like that and run again.
It could be due to too little memory. You can modify the eclipse.ini file to increase the memory. Something like this might help you: FAQ How do I increase the heap size available to Eclipse?

Java -version prints a wrong version

I have multiple versions of Java installed in the environment(I know it is bad). I've set the JAVA_HOME to jdk 1_4 directory. This is not installed, but extracted from zip and placed it somewhere. We have java 1.8 JRE also installed in the system. I never set the path to this installed directory. Now i'm trying to run some ant script that depends on jdk 1_4. I get some exception saying that it is not able to find tools.jar in java1.8... .
My question is that when the path and java_home are set to jdk 14 why does the ant look for 1.8 version of java? I'm confused.
Update: I have looked up the duplicate issue.
Additional details: Java -version prints 1.8 with jdk 14 in the path and java_home. I uninstalled 1.8. reopened cmd tried java -version, now it errors out saying that it is not able to find java1.8 instead of trying to find the next java available in the path or java_home.
Error shown:
C:\Users\usrpao>java
Error: could not open `C:\Program Files\Java\jre8\lib\amd64\jvm.cfg'
I have multiple versions of Java installed in the environment(I know it is bad). I've set the JAVA_HOME to jdk 1_4 directory.
Not wrong at all. I have a similar setup because I have to switch between Java version.
First, install Java JDKs in the root of your drive. No spaces in the directory names. For example, C:\Java\Java-1.6-21 and C:\Java\Java-1.7-5.
In your Environment Variables section in your System Control Panel (under Advance), create an environment variable to point to each one of these Java Home directories. For example, JAVA_HOME_17 = C:\Java\Java-1.7.5 and JAVA_HOME_16 = C:\Java\Java-1.6-21. This should be a System Environment variable.
Create a JAVA_HOME environment variable that points to the Java version you want: JAVA_HOME = %JAVA_HOME_17%.
Now in the System PATH, prefix the PATH (the very first entry) with %JAVA_HOME%\bin.
When you open a console window, your default java and javac commands will be the correct Java version.
If you need to change a version, change the JAVA_HOME environment variable to point to the correct environment variable and open a new console window. Now that new Java will be in your path.
NOTE: It is vitally important that %JAVA_HOME%\bin is in the first part of your PATH before C:\Windows\System32. You don't want the java.exe that exists in that directory to be your default java.
You haven't specified the operating system, so:
on windows, java installs a java.exe in C:\Windows\system32, which is probably on the path before java_home, and so gets picked up
on Linux, various distributions that support multiple installed java versions will also have some symlink earlier on the path. Run 'which java' to determine where that symlink is
Multiple java versions in the system is the problem, I uninstalled all the java versions first. Restarted my machine. Path and java home points to the jdk 1.4. java -version now points to the version specified in the path. Thanks all.

A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse

Tried googling but couldn't found the solution.
Using Windows 7 Ultimate 64 bits.
I have java(64 bits) installed here : C:\Program Files (x86)\Java\jre7
Downloaded Android SDK from here Get the Android SDK
I downloaded the 64 bits considering my windows is 64 bits. Was 32 bits required?
Now whenever i run eclipse.exe I get the following error:
A Java Runtime Environment or JDK must be available in order to run Eclipsec. No java virtual machine was found after searching the following location:
C:\Users..\Downloads\adt-bundle-windows=x86_64-3013131030\adt-bundle-windows-x86_64-20131030\eclipse\jre\bin\java.exe
Sorry can't post a screenshot because don't have any reputation as of now here.
So what should I do?
Do I need to install 32 bit Java or download 32 bit SDK ?
PS: Before running Eclipse I have run "SDK Manager" and it installed some necessary tools. Maybe if this helps.
Just Set your environment variable. Goto to Computer properties -> Advance System Setting -> Environment variables -> System Variables -> path and after a semi colon paste the path of your JRE like this C:\Program Files\Java\jre7\bin click on ok.
Open CMD and type java if this command works properly means your path has been set now. just open you eclipse and it will work this time. You can do this through command line too just type set PATH=C:\Program Files\Java\jre1.6.0_03\bin and press enter.
If still it is not working just paste this set PATH=C:\Program Files\Java\jre1.6.0_03\bin in your eclipse.ini file :)
You have a 32-bit Java. "Program Files (x86)" is for 32-bit programs on a 64-bit system. Either install a 64-bit Java and use the download you have, or get the 32-bit download.
You need to use any of the following configurations:
x64 System, x64 JDK, x64 ADT Bundle
x64 System, x86 JDK, x86 ADT Bundle
x86 System, x86 JDK, and ADT Bundle

JAVA_HOME and java -version

I'm using a Windows .bat script and I set JAVA_HOME as C:/Program Files/Java/jdk1.6.0_32
when I do a java -version, it still shows the 1.3
How can I fix this? What am I doing wrong?
For me the issue was in my PATH variable, C:\ProgramData\Oracle\Java\javapath; was added by java windows install before my %JAVA_HOME%\bin;.
So I'd echo %JAVA_HOME% pointing to a JDK7 and java -version showing jdk8.
I'd to put %JAVA_HOME%\bin; before C:\ProgramData\Oracle\Java\javapath; so that java -version displays jdk7.
Try %JAVA_HOME%\bin\java -version
If you modify JAVA_HOME, it's usually better to invoke java with an absolute path (using JAVA_HOME) because the new binary is probably not in the path (and then Windows will load the wrong binary).
Make sure that the PATH environment variable is pointing to %JAVA_HOME%\bin.
Be sure not to mix the system variable path and the user variable system path. I feel OK in calling java without the absolute path (when I know how JAVA_HOME and PATH are configured).
Calling java -version from command line, causes cmd.exe to do the lookup on the "known" directories. "Known" means PATH environment variable. It seems that your PATH contains a java 1.3 bin folder, and not 1.6.
JAVA_HOME is another variable, that is used (for example, and not only) by java wrappers, or by scripts executing some java stuff.
Try doing this:
SET JAVA_HOME=C:/Program Files/Java/jdk1.6.0_32
%JAVA_HOME%/bin/java -version
Add quotes where needed.
I had similar issue,in my case , I had two versions java installed. it can be fixed by uninstalling one version of java completely from system.
Had a similar scenario today - two Windows 10 devices - both have JRE 1.6 & 1.7.
When typing
Java -version
One device shows 1.6 the other 1.7.
This was preventing me running a third party JAR to install some software on the device showing 1.6 (which worked fine on the device showing 1.7 when running java -version), using:
java -jar ThirdParty.jar
As the JAR needed to be run by 1.7.
Cause of this was in the PATH environment variable - one device had the location of 1.6 first in the PATH list, moving the 1.7 location above the 1.6 location resulted in consistency using Java -version and allowed me to install the software.
java -version will consult the paths in the special environment variable Path. You need to select the java version you want and move it upwards the latter (click "Move Up"). You probably have that reference to JDK 1.3 in Path above your addition of JDK 1.6. Since that's the first thing the OS finds, that's what it chooses to run.
Executing the command again with the same window opened after changing the environment variables will not work. Re-open it
I know this question is old but this was my case and I wanted to re-explain further, similar to #DanBot 's case

Categories

Resources