Javac and java pointing to different environments

2019-03-18 14:13发布

Please Help, I am trying to run a compiled java class and getting errors but when I try to check my java environments it points different ways as seen below

c:\NetBeansProjects\Hello\src>javac -version
javac 1.7.0

c:\NetBeansProjects\Hello\src>java -version
java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b05)
Java HotSpot(TM) 64-Bit Server VM (build 20.6-b01, mixed mode)

According to my PC(windows 7) I have

C:\Program Files (x86)\Java
jdk1.6.0_25
jdk1.7.0
jre6
jre7

How can I point it all to Java 7 or only Jave 6.....just want to try java 7 to see the fastness compared to java 6...hope all I have written helped.

Cheers.

标签: java cmd
5条回答
淡お忘
2楼-- · 2019-03-18 14:43

Look at your path - I suspect c:\Windows\System32 is ahead of the JDK7 directory... and I suspect that's Java 6 for whatever reason.

查看更多
时光不老,我们不散
3楼-- · 2019-03-18 14:43

In the PATH variable enter C:\Program Files (x86)\Java\jdk1.6.0_25\bin before the path of system32. It fixed my problem Just make sure java's path is the first path in the "PATH" environment variable

查看更多
我只想做你的唯一
4楼-- · 2019-03-18 14:47

In all likelyhood, you have installed a JDK 7 and a JRE 6 and in your PATH environment variable the JRE bin path is before your JDK bin path

查看更多
三岁会撩人
5楼-- · 2019-03-18 14:58

You have the jre/bin directory on the system path before the jdk/bin. The javac command doesn't exist in the jre installation.

Thus the java command gets the version under jre6 but javac gets the version under jdk1.7.0.

You should change your system path to only include the one you want. If you want to explicitly use one over the other use the absolute name (including path) instead of just the executable name.

查看更多
家丑人穷心不美
6楼-- · 2019-03-18 15:06

I'ts just because of your path, JRE does not contain javac and it contains java, so in your path the JRE must be located before the JDK

查看更多
登录 后发表回答