3

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.

asked Mar 25, 2015 at 12:03
3
  • which operating system is it? Commented Mar 25, 2015 at 12:09
  • 1
    Are you using an IDE like Eclipse or something? Commented 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. Commented Mar 25, 2015 at 12:24

5 Answers 5

2

Java installation under Windows is sometimes a really severe source of pain. The following assumes that you have Windows:

  1. Check your path variable
  2. Check JAVA_HOME variable
  3. 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)
  4. 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, ...

answered Mar 25, 2015 at 12:09
Sign up to request clarification or add additional context in comments.

7 Comments

i will check my system32 directory
Sebastian...it works..I removed java,javaws and javaw .exe files from system32 folder. Thanks alot !!
@NithinVarghese, if it worked, mark this answer as the correct one. It will increase Sebastian's reputation (he deserves xD) and can help other people with same problem.
I don't think it is safe to delete 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.
I think is safer not use internet explorer ;)
|
1

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

answered Mar 25, 2015 at 13:29

Comments

1

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;
answered Mar 25, 2015 at 12:17

Comments

0

If you are running Windows, you could perhaps check the path environment variable. It might point to an older JRE installation.

answered Mar 25, 2015 at 12:04

5 Comments

I checked the enviorment variables,thats not the issue .Both the java_home and path is pointing to 1.8 version
I assume you have a second JRE with version 1.6.2 installed?
yes i do have 1.6 version also installed but i am not setting any env varibles for 1.6 version
@NithinVarghese, check Sebastian's answer. You probably have your java command under system32, which it usually has preference over %JAVA_HOME% in your PATH enviroment variable. If exisits, delete it.
@Albert...i deleted java,javaw and javaws .exe files from system32 folder and it work fine now.
0

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)

answered Mar 25, 2015 at 12:13

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.