I am trying to run a compiled java class and getting errors but when I checked my java environments it points to different version.
Javac –version gives me 1.8.0
And
Java –version gives me 1.6.2
The Java_home and path is pointing to the 1.8 version.
Please help.
-
which operating system is it?Steven Pauk– Steven Pauk2015年03月25日 12:09:12 +00:00Commented Mar 25, 2015 at 12:09
-
1Are you using an IDE like Eclipse or something?Dima Maligin– Dima Maligin2015年03月25日 12:09:16 +00:00Commented Mar 25, 2015 at 12:09
-
When set the path set it like set PATH=%JAVA_HOME%\bin;%PATH% .. It will put your JAVA bin folder in first before others.Naveen Ramawat– Naveen Ramawat2015年03月25日 12:24:13 +00:00Commented Mar 25, 2015 at 12:24
5 Answers 5
Java installation under Windows is sometimes a really severe source of pain. The following assumes that you have Windows:
- Check your path variable
- Check JAVA_HOME variable
- Newer versions of Java (1.6 ?, but 1.7 and 1.8) copy some Java executables into the System32 directory of the windows installation. Simply delete this files (or move them somewhere else for easy recovery)
- running java applications by using .bat files a specific JDK / JRE can be provided.
There may be more sources of your problem. For example with Maven you depend on JAVA_HOME, with Eclipse you have the project settings, ...
7 Comments
java.exe files from system32 folder. Internet explorer (maybe other applications too) use this jre to run applets. The correct way is highlighted in my answer.Please check the following :
1) Check your path variable
2) Check JAVA_HOME variable
3)Delete the java,javaw and javaws .exe file from the system32 folder
Comments
java.exe while java installation gets copied under System32 directory. Also we tend to append java path in the end of the path variable. This causes running java command pointing to the one in System32 (it takes the first path value that is encountered and ignores rest, in this case java of system32 folder). And when it cannot find javac it looks to other values of path and finds it towards the end for the java JDK (this is the one you want to use).To overcome this problem give path to your JDK for example C:\ProgramData\Oracle\Java\bin as the first entry in the windows path variables. Even before your system32 entry. This ensures you point to only one java. My path entry looks something like this:-
%JAVA_HOME%\bin;%SystemRoot%\system32;
Comments
If you are running Windows, you could perhaps check the path environment variable. It might point to an older JRE installation.
5 Comments
java command under system32, which it usually has preference over %JAVA_HOME% in your PATH enviroment variable. If exisits, delete it.One possibility is that your Java link is inconsistent. Go to this location (Windows):
C:\ProgramData\Oracle\Java\javapath and check where to does java.exe point.
In case it is not up-to-date consider fixing it with:
mklink /d C:\ProgramData\Oracle\Java\javapath "C:\Program Files\Java\<your JDK>\bin\"
(you may need to remove javapath old link before you create a new one)