How to install Apache Ant on Windows 7 - java

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

Related

'wsimport' is not recognized as an internal or external command

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?

Running gradle -v returns "JAVA_HOME is set to an invalid directory" even though I have a valid JAVA_HOME

I'm trying to install and use gradle 2.7
I have java installed properly:
java -version
java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)
I have my JAVA_HOME set correctly:
echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home
When I run gradle -v:
ERROR: JAVA_HOME is set to an invalid directory: /Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
I tried to use the solution given here Gradle does not recognize the JAVA_HOME I have set and here Gradle finds wrong JAVA_HOME even though it's correctly set
but that line does not exist in my gradle file located at /usr/local/gradle/gradle-2.7/bin
Does anyone have any other suggestions?
Edit:
cat ~/.bash_profile
export JAVA_HOME=$(/usr/libexec/java_home)
export JDK_HOME=$(/usr/libexec/java_home)
export PATH=/Users/eghdk/Dev/Android/SDK/platform-tools:/Users/eghdk/Dev/Android/SDK/tools:$PATH
export ANDROID_HOME=/Users/eghdk/Dev/Android/SDK
# Adding Gradle to system path
export GRADLE_HOME=/usr/local/gradle/gradle-2.7
PATH=$GRADLE_HOME/bin:$PATH
export PATH
# Turning on the Gradle daemon by default
export GRADLE_OPTS="-Dorg.gradle.daemon=true"

Getting different version for java and javac

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"

Two installed javas on same pc. The one with lower version can not be called

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.

Maven Installation - Environment Variables

I am using Maven for the first time on Windows 7 and getting this error:
ERROR: JAVA_HOME is set to an invalid directory.
JAVA_HOME = "C:\Program Files\Java\jdk1.7.0_03\bin"
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation
Java version "1.6.0_29" Java(TM) SE Runtime Environment (build
1.6.0_29-b11) Java HotSpot(TM) Client VM (build 20.4-b02, mixed mode)
I've read everywhere online about how to set up the variables properly in windows for a Maven installation, also on this site, but, I can't seem to get my installation working.
Here's my set-up:
System Variables:
JAVA_HOME
C:\Program Files\Java\jdk1.7.0_03\bin
Path
C:\apache-maven\src\bin
Any help would be greatly appreciated.
thats because your JAVA_HOME is incorrect
set JAVA_HOME to C:\Program Files\Java\jdk1.7.0_03
also some systems , maven might still throw error because if the path to Java Directory has space i.e Space between Program and Files in the path
You might as well move the java to someother path without space
instead of
C:\Program Files\Java\jdk1.7.0_03
to
C:\Java\jdk1.7.0_03
Edit
Double-quoting the value of JAVA_HOME can also cause this problem
set JAVA_HOME="C:\Program Files\Java\jdk1.6.0"
doesn't work for me, but this does:
set JAVA_HOME=C:\Program Files\Java\jdk1.6.0
set JAVA_HOME to C:\Program Files\Java\jdk1.7.0_03 (without bin)
For environment variable of JAVA_HOME should be like this "C:\Program Files\Java\jdk1.7.0_03\" without bin. Please note that likely you have 2 version of Java installed. Make sure which one that you want to use.
Seemed it was a problem with the latest version of Maven. I used Maven 2.2.1 with the same set-up and it run with no problems.
JAVA_HOME should be like this C:\PROGRA~1\Java\jdk1.7.0_03
Hope this will work!

Categories