LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to set Ant and Java Home ? (http://www.linuxquestions.org/questions/linux-newbie-8/how-to-set-ant-and-java-home-843829/)

albertwt 11-12-2010 02:49 AM

How to set Ant and Java Home ?
 
Hi All,

I've successfully installed Java and Ant using apt-get, however when i tried to echo the env. variable, I doesn't give me anything ?

But, i can see some result here:
Quote:

root@SSV:~# java -version
java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03, mixed mode)

root@SSV:~# ant
Buildfile: build.xml does not exist!
Build failed
is that working configuration or i shall add it into /etc/environment file like the following ?

Quote:

root@SSV:~# whereis ant
ant: /usr/bin/ant /usr/share/ant /usr/share/man/man1/ant.1.gz

root@SSV:~# whereis java
java: /usr/bin/java /etc/java /usr/share/java /usr/share/man/man1/java.1.gz
root@SSV:~#
Any help would be greatly appreciated.

Thanks,

Albert

crabboy 11-12-2010 10:51 PM

You may want to set the ANT_HOME and JAVA_HOME environment variables, but other that than it looks like it is working.

You can always test it out, put both files in a directory and run ant.

test1.java
Code:

class test1
{
  public void main()
  {
      System.out.println("Hello");
  }
}

build.xml
Code:

<?xml version="1.0"?>

<project name="test1" default="all">

        <target name="compile">
                <echo message="Compiling..."/>
                <javac srcdir="." destdir="." includes="test1.java" />
        </target>

        <target name="all" depends="clean,compile"/>

        <target name="clean">
                <echo message="Cleaning..."/>
                <delete failonerror="false">
                        <fileset dir="." includes="test1.class"/>
                </delete>
        </target>

</project>


albertwt 11-12-2010 11:08 PM

wow, thank you very much man, I learn so much with this way.


All times are GMT -5. The time now is 11:57 PM.