There are a few of these questions. But my PATH variable is correct
;%JAVA_HOME%\bin;
My JAVA_HOME is C:\Program Files\Java\jdk1.8.0_131
When I type java -version, I get
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
echo %JAVA_HOME% and echo %PATH% return what they are supposed to. What can be the reason wsimport doesn't work?
My full PATH is
C:\Informatica\9.5.1\clients\DT\bin;C:\Informatica\9.5.1\clients\tools\datadirect;C:\Informatica\9.5.1\clients\tools\odbcdrv;C:\oracle\client_1\bin;C:\ProgramData\Oracle\Java\javapath;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%systemroot%\System32\WindowsPowerShell\v1.0\;%systemroot%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Skype\Phone\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\PuTTY\;C:\Program Files (x86)\PuTTY\;%JAVA_HOME%\bin;%ZOOKEEPER_HOME%\bin;C:\Program Files\Git\cmd;C:\Program Files\apache-maven-3.5.0\bin;
%JAVA_HOME%\bin won't work in %PATH%. It should be full path without variables. There is no variable expansion when OS search for executable.
Your java executable found in some system folder.
I suppose %SystemRoot% is some sort of special case.
Solution
Replace %JAVA_HOME%\bin by real path.
Firstly, try to check javac -version. Maybe you provide some wrong path for JDK and system recognize only JRE path.
What is echo %PATH% output? Is there some different path for java before ;%JAVA_HOME%\bin?
Related
I have set up Java in Windows environment variable, but when I type java -version it is not taking the path specified.
So the user path has
%JAVA_HOME%\bin
And the value of JAVA HOME is
M:\java\java-se-8u41-ri // this points to jdk 8
When I type java -version, I get
java version "1.8.0_301"
Java(TM) SE Runtime Environment (build 1.8.0_301-b09)
Java HotSpot(TM) Client VM (build 25.301-b09, mixed mode, sharing)
This is not JDK. Why is this happening and how can I solve it?
EDIT : this is what i'm expecting
openjdk version "1.8.0_41"
OpenJDK Runtime Environment (build 1.8.0_41-b04)
OpenJDK Client VM (build 25.40-b25, mixed mode)
EDIT 2
information requested
echo %JAVA_HOME%
M:\java\java-se-8u41-ri
where java
C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.exe
M:\java\java-se-8u41-ri\bin\java.exe
echo %PATH%
C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Program Files\PostgreSQL\13\bin;C:\Program Files\PostgreSQL\13\lib;C:\Program Files\nodejs\;M:\java\java-se-8u41-ri\bin;C:\Program Files\nodejs;C:\Program Files\sfdx\bin;M:\maven\apache-maven-3.8.3\bin;
First, a great thanks to #Mark Rotteveel and #Christian.
The issue was there were multiple Java installations (as visible in where java).
The path variable was pointing to Oracle Java at first and was ignoring the Java that I wanted it to point, once I removed it from the path, it started working fine.
Before marking it duplicate FYI I have already read How can I change the Java Runtime Version on Windows (7)? and How to set path for Jre 6 when jre 7 installed?.
I have both Java7 and Java8 in my machine. I have
JAVA_HOME = C:\Program Files\Java\jdk1.7.0_60
PATH = ...;%JAVA_HOME%\bin;....
but I am getting
C:\>java -version
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)
C:\>javac -version
javac 1.7.0_60
I want to set JRE to 1.7 too. How to do that?
You will probably have to edit your path environment variable.
If you want to check what's in your PATH environment variable in an organized fashion, run:
echo %path:;=&echo.%
Make sure the 1.8 is not on the path or if you want it there make sure it appears after 1.7.
To edit it, go to My Computer > Properties > System Properties > Advanced tab > Advanced section > Environment Variables.
Also check what is actually launched when you run java from the command line, run the following command:
where java
It will show you what windows runs when you request java.
To solve the problem, remove or change the name of java.exe and javaw.exe into System32 folder:
Prepend the System Variable's Path with JRE bin's path.
where java did work for me. I found there is another version of java associated with the SPSS (1.8.0). Uninstall SPSS and the problem solved.
The solution that worked for me was:
In "Path" variable replace "C:\ProgramData\Oracle\Java\javapath;" with %JAVA_HOME%\bin where JAVA_HOME variable was set to "C:\Program Files\Java\jdk1.7.0_60"
I want to install Apache ant on windows. Here is some information below:
http://ant.apache.org/manual/install.html
Error installing Ant: ANT_HOME is set incorrectly
I followed its descriptions and step by step but it still cannot work.
I think the entire environment variables I set are correct. May please someone helps me? And some copies from cmd.
C:\>echo %ANT_HOME%
C:\Program Files\apache-ant-1.9.4
C:\>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.6.0_34
C:\>java -version
java version "1.6.0_34"
Java(TM) SE Runtime Environment (build 1.6.0_34-b04)
Java HotSpot(TM) Client VM (build 20.9-b04, mixed mode, sharing)
C:\>ant
is not recognized as an internal or external command,operable program or batch file.
My Ant version is 1.9.4
I think the path is not set properly.
set JAVA_HOME=C:\Program Files\Java\jdk1.7.0
set ANT_HOME=D:\software\apache-ant-1.9.4
set PATH=%PATH%;%JAVA_HOME%\bin;%ANT_HOME%\bin
Edit: fixed PATH definition
Change your path From:
C:\Program Files\apache-ant-1.9.4
C:\Program Files\Java\jdk1.6.0_34
To:
C:\Progra~1\apache-ant-1.9.4
C:\Progra~1\Java\jdk1.6.0_34
When setting the paths.
Change you path , not install on C:\Program Files\
Add Path, like:
set PATH=%PATH%;%JAVA_HOME%\bin;%ANT_HOME%\bin
So I was trying to set my JAVA_HOME variable for a program and though I was sure I set the right directory the program was printing:
The system cannot find the path specified.
I did some testing and now I'm just baffled.
Other info:
C:\Program Files\Java\jre7\bin>java.exe -version
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)
Windows version
OS Name: Microsoft Windows 8.1 Pro
OS Version: 6.3.9600 N/A Build 9600
The cd command handles paths with spaces but dir requires that you quote the path if it contains spaces.
dir "%JAVA_HOME%"
will do what you expect.
The issue is that cd expects only one path, so even if the path contains a space it's still treated as a single string. dir can handle multiple paths, delimited by spaces, so when %JAVA_HOME% gets expanded you get
dir C:\Program Files\Java\jre7\bin
which contains TWO paths (as seen by the dir command), neither of which exists:
C:\Program
Files\Java\jre7\bin
I have two javas installed on my pc. jdk1.7.0_45 (x64) and jdk1.6.0_45(x86). I want that default java on my machine would be jdk1.6.0_45(x86). I added JAVA_HOME with value C:\Program Files (x86)\Java\jdk1.6.0_45 and added C:\Program Files (x86)\Java\jdk1.6.0_45\bin to system path, but still when i type in command prompt "java -version" it says:
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
I have no idea why the things are like that, because my OS should see jdk1.7.0_45 (x64) version. Why is that so?
I use windows 8
edit:
after setting java home to jdk1.7.0_45 (x64) folder and updating path accordingly javac works, but then I set java home and path to jdk1.6.0_45(x86) javac does not work.
You need to add the %JAVA_HOME%\bin to the very beginning of your path. This is because Java is installed in your %SystemRoot%\system32, too. If you add the %JAVA_HOME%\bin to the beginning of your path the Java installed in your JAVA_HOME will be used.
JAVA_HOME does not help when we run java from command line, you should fix PATH system var
I added JAVA_HOME with value C:\Program Files (x86)\Java\jdk1.6.0_45
In Windows, you should excape spaces in the path: JAVA_HOME="C:\Program Files (x86)\Java\jdk1.6.0_45". But the best way is to set Java to a folder that doesn't have spaces in its path. For example, I use C:\Java\Java6
and added C:\Program Files (x86)\Java\jdk1.6.0_45\bin to system path
Probably you added after path to the Java 7. Make sure that Java 7 doesn't exist in the system path.