Solved

Ant Installation. Getting errors on Fedora...

Posted on 2008-10-13
25
861 Views
Last Modified: 2013-11-10
Hello Experts,

I am trying to get Ant 1.7 going on centOS 5.2. When I type ant on shell, I get the following errors:

[code]
/usr/bin/build-classpath: error: Could not find xml-commons-apis Java entension for this JVM
/usr/bin/build-classpath: error: Some specified jars were not found Buildfile: build.xml does not exist!
Build failed
[/code]

Appreciate any help on this.

Thanks a lot
0
Comment
Question by:combustion007
  • 16
  • 9
25 Comments
 
LVL 2

Expert Comment

by:rsneale
ID: 22704230
I am guessing but it appears that you are using /usr/bin/java supplied by your centos dist. (GCI)    I have not gotten this jvm to function in a dev environment.   I must admit that my typical response is to go straight  to javasoft.com and get the Sun JDK .   I am sure what they have supplied is reasonable jvm but...
0
 
LVL 2

Expert Comment

by:rsneale
ID: 22704395
A little more.   I have to machines,

cat /etc/redhat-release
Fedora release 8 (Werewolf)
/usr/bin/java -version
java version "1.7.0"
IcedTea Runtime Environment (build 1.7.0-b21)

and

cat /etc/redhat-release
Fedora release 8 (Werewolf)
/usr/bin/java -version
java version "1.4.2"
gcj (GCC) 3.4.6 20060404 (Red Hat 3.4.6-9)

Neither supply javac or the full library set for java development which is typically necessary when using ant.

So I would get: http://java.sun.com/javase/downloads/?intcmp=1281       Java 6 Update 7 JDK
Set JAVA_HOME to the installation directory and set PATH to $JAVA_HOME/bin  before the definition of /usr/bin and you should be set with all the tooks that ant calls for.


0
 
LVL 2

Expert Comment

by:rsneale
ID: 22704398
A little more.   I have to machines,

cat /etc/redhat-release
Fedora release 8 (Werewolf)
/usr/bin/java -version
java version "1.7.0"
IcedTea Runtime Environment (build 1.7.0-b21)

and

cat /etc/redhat-release
Fedora release 8 (Werewolf)
/usr/bin/java -version
java version "1.4.2"
gcj (GCC) 3.4.6 20060404 (Red Hat 3.4.6-9)

Neither supply javac or the full library set for java development which is typically necessary when using ant.

So I would get: http://java.sun.com/javase/downloads/?intcmp=1281       Java 6 Update 7 JDK
Set JAVA_HOME to the installation directory and set PATH to $JAVA_HOME/bin  before the definition of /usr/bin and you should be set with all the tooks that ant calls for.


0
 
LVL 2

Expert Comment

by:rsneale
ID: 22704418
Sorry, for the pasting error, my second os is:

cat /etc/redhat-release
CentOS release 4.6 (Final)
0
 

Author Comment

by:combustion007
ID: 22705247
Hello rsneale,

Thank a million for your help. I am very new to linux and have been trying for days to get everything going. When I got the dedicated hosting server, it came with java 1.4.2 (shell java -version). So then I went a head downloaded:

jdk-6u7-linux-i586-rpm.bin

and installed it under: /user/lib/jdk1.6.0_07/

and then established a symbolic link for the jdk1.6.0_07 directory to jdk. Now when I open /usr/lib/, I see jdk link pointing to jdk1.6.0_07.

Then I went to /etc/profile and edited the paths like this:

export JAVA_HOME="/usr/lib/jdk";
export JRE_HOME="/usr/lib/jdk";
export ANT_HOME="/usr/lib/jdk";


and rebooted.

Now when I try to find the java version at the shell (java -version) I still get the old 1.4.2. I don't know what else to do. I am attaching my profile file as well.
profile-txt.txt
0
 
LVL 2

Expert Comment

by:rsneale
ID: 22705487
Ok,  Several issues:

1) export ANT_HOME="/usr/lib/jdk"   # should point to the ant dist that you installed not here!  I would put ant into /usr/local/apache-ant...
2) export JAVA_HOME="/user/lib/jdk1.6.0_07"    #   I copied your line.   I suspect it is /usr/lib...  typically this is in /usr/local for thirdparty installs.   You can move this directory and it will not have any repercussions.  Adjust #2 accordingly.
3) export PATH=$ANT_HOME/bin:$JAVA_HOME/bin:$PATH  # This will get everything visable to the cmd line.   Note, this will oclude the /usr/bin/java et. al.
4) Rebooting not necessary, but ok.   Just do a 'which javac' or 'java -version' and 'ant -version'
5) I would be careful of symlinks in /usr

Try the first three and
0
 
LVL 2

Expert Comment

by:rsneale
ID: 22705858
Just looked at the changes you make to /etc/profile and while you can make changes here, the correct way is to put the exports into a file /etc/profile.d/java.sh and java.csh  such as:

export ANT_HOME=/usr/local/apache-ant-1.7.0
export JAVA_HOME=/usr/local/jdk1.6.0_07
export PATH=$ANT_HOME/bin:$JAVA_HOME/bin:$PATH

You can add some check later for existance and such but  this is what you would do in system space.  This is directory auto loads the contents to the env

The more typical way is to add the lines to ~/.bashrc or ~/.bash.profile and not muck in the system space.
0
 

Author Comment

by:combustion007
ID: 22705880
Ok, so I have made your suggested changes and now the /etc/profile/ looks like this:

export JAVA_HOME="/usr/lib/locat/jdk1.6.0_07/";
export JRE_HOME="/usr/lib/locat/jdk1.6.0_07/jre/bin/";
export PATH=$ANT_HOME/bin:$JAVA_HOME/bin:/usr/lib/ant/


I tried to shell which javac:

I get: /usr/bin/javac

And when I do java -version, I still get 1.4.2

Thanks a lot.
0
 
LVL 2

Expert Comment

by:rsneale
ID: 22705953
First, sorry for the double posts.  I have no clue how this is happening.   I have switched machines.  Hope it helps.

Before we do the /etc/profile, do these steps in your shell.   Please comment out the lines in the profile till we get things working !!!!!!!!!!!   Your missing the trailing $PATH and if not careful,  you could hose your access to the OS.

Please send the results to echo $PATH
0
 
LVL 2

Expert Comment

by:rsneale
ID: 22706466
I have not heard back from you and I am very worried.  

You said that you have placeed

export PATH=$ANT_HOME/bin:$JAVA_HOME/bin:/usr/lib/ant/

into /etc/profile

Warning:  The syntax is incorrect in that it does not contain the trailing :$PATH thus you do not pull in the rest of the valid paths such as /bin and /usr/bin.   This will give a truncated path to anyone logging on.  Very bad!     Please do not work in /etc/profile untill you have things sorted out.   Work in your shell!

I had suggested that you use:
export PATH=$ANT_HOME/bin:$JAVA_HOME/bin:$PATH

I also suggested that ANT_HOME be defined.   Thus the trailing :/usr/lib/ant/ would not be necessary (using your location).
export ANT_HOME=/usr/lib/ant
export PATH=$ANT_HOME/bin:$JAVA_HOME/bin:$PATH

Please get back to be for I fear the worst.   All users logging in to your system have a bad PATH and can not see any std unix executables in:   /bin:/usr/bin:/usr/X11R6/bin
0
 

Author Comment

by:combustion007
ID: 22708002
Hello rsneale,

Thank you so much for your concern, you were right, I did do some damage and wasn't able to run any commands. Luckily, I had made a backup of the /etc/profile so I sshed in and restored the profile and was able to get back in and now all is running well. wheeeeeeeeeph.. I have been at day and nigth for the past two weeks getting things going with FEDORA. Have learned a gr8 deal but still got ways to go.

This is where I am currently  at:

#export JAVA_HOME="/usr/lib/locat/jdk1.6.0_07/";
#export JRE_HOME="/usr/lib/locat/jdk1.6.0_07/jre/bin/";
#export PATH=$ANT_HOME/bin:$JAVA_HOME/bin:/usr/lib/ant/

I have commented out all three lines like you had suggested. I have moved jdk1.6.0_07 to /usr/local/ and have also moved ant to /usr/local/ as well. I really appreciate your help.

Thanks a million.
0
 
LVL 2

Expert Comment

by:rsneale
ID: 22708158
You had me sweating there.   Thankfully you recovered.   The curve can sometimes be steep and we all have been there.   The move of the dists is good.  Best to stay out of /usr and /usr/bin and leave it to rpm installs to do the appropriate install.

Note, I would retain the package name for the apache-ant-1.7.0 .  it is typical to do a symlink to get the ant or java simple name:

ln -s apache-ant-1.7.0 ant
ln -s jdk1.6.0_07 java

This allows for easily slipping in a new version and repoint the link.

Now, execute each of the lines I suggested in your bash shell cmd line.  
export ANT_HOME=/usr/local/apache-ant-1.7.0
export JAVA_HOME=/usr/local/jdk1.6.0_07
export PATH=$ANT_HOME/bin:$JAVA_HOME/bin:$PATH

Given that  which and -version tests are successful,   put the  lines into  ~/.bash.profile
This executes on first login and will be retained for all your processes.  Some folks put it in .bashrc which executes on the creation of a new process.  Much more frequent and create an overhead.

Now, you probably went down the /etc/profile track because you wanted  to make this available to others.   This is where /etc/profile.d comes into play.    /etc/profile will review all the scripts appropriate for the user login shell and source them.   That means it will  set them in your environment.  You shoud not modify /etc/profile itself!

Clear as mud ?
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:combustion007
ID: 22708463
Hello rsneale,

Thank you so much, I followed on as you suggested and made all the changes. Created the ~/.bash.profile and then copied all three lines:

export ANT_HOME=/usr/local/apache-ant-1.7.0
export JAVA_HOME=/usr/local/jdk1.6.0_07
export PATH=$ANT_HOME/bin:$JAVA_HOME/bin:$PATH

and now when I do which javac, I do get 1.6.0_07.

I really appreciate this. Can you please tell me what do I need to do to get ANT working. Currently when I type ant on shell I get :

/usr/bin/build-classpath: error: Could not find xml-commons-apis Java entension for this JVM
/usr/bin/build-classpath: error: Some specified jars were not found Buildfile: build.xml does not exist!
Build failed

Thank you.
0
 
LVL 2

Expert Comment

by:rsneale
ID: 22711928
Please let me know the following:

echo $ANT_HOME
echo $JAVA_HOME
echo $PATH
java -version
ant -version

0
 

Author Comment

by:combustion007
ID: 22712326
Good morning rsneale,

this is what I am getting now:

echo $ANT_HOME
returns to the next shell line (displays nothing)

echo $JAVA_HOME
returns to the next shell line (displays nothing)

echo $PATH
returns:

/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin1

java -version
returns: '1.4.2

ant -version
returns:

/usr/bin/build-classpath: error: Could not find xml-commons-apis Java entension for this JVM
/usr/bin/build-classpath: error: Some specified jars were not found Buildfile: build.xml does not exist!
Build failed

Lastnight It was showing java -version as 1.6.0_07...

Thanks a lot.
0
 
LVL 2

Accepted Solution

by:
rsneale earned 500 total points
ID: 22712444
Ok, you said that you had modified .bash_profile and added something to the effect of:

export ANT_HOME=/usr/local/apache-ant-1.7.0
export JAVA_HOME=/usr/local/jdk1.6.0_07
export PATH=$ANT_HOME/bin:$JAVA_HOME/bin:$PATH

If this not the case,  just type this in the current shell.   We can add it to the scripts later.

Now at the shell type the following noting the dot space before the .bash_profile:

.  ~/.bash_profile

This executes the .bash_profile in the current shell and not in a sub-process so any definitions will be retained in the current shell rather than being lost when a sub-process exits.

Now redo the echo and version stmts.
0
 
LVL 2

Expert Comment

by:rsneale
ID: 22712912
I am going to assume that you have gotten some reasonable output from the last step and are ready for the next.    If not we can continue to work the issues.    If you can now do a ant -version then create a file called build.xml in the current directory and add the contents from the attached snippet.    Now do an 'ant'  or more formally, 'ant -f build.xml'.    This should now show the echo and you are good 2 go.
<project name="HelloWorld"

         default="info"

         basedir=".">
 

    <target name="info" description="Let the world know we here">

        <echo message="Hello World" />

   </target>

</project>

Open in new window

0
 

Author Comment

by:combustion007
ID: 22712994
Hey rs,

I tried executing by:

.  ~/.bash_profile

after entering this command, I am taken to the next shell line ( nothing happens). And when I run the echo statements still I get the same results as the last time.


I am attaching the /root/.bash_profile, I am not sure if it help any.

Thanks a lot


# .bash_profile
 

# Get the aliases and functions

if [ -f ~/.bashrc ]; then

        . ~/.bashrc

fi
 

# User specific environment and startup programs
 

PATH=$PATH:$HOME/bin
 

export PATH

unset USERNAME

Open in new window

0
 
LVL 2

Expert Comment

by:rsneale
ID: 22713275
Ok, I see the problem,   Last night circa 7:08PM PDT I had a typo in the name of the .bash_profile  I had typed .bash.profile  (dot vs underscore)

Just type the three export lines in the shell and send the echo/which statements.   Putting the lines in the .bash_profile file is the next step.

I am really trying to help here and would like to get you get ant going.
0
 

Author Comment

by:combustion007
ID: 22713957
Hello rs,

I cannot thank you enough, I wouldn't mind if you want to login to the server and have a look yourself. I have followed your suggestion and this is the outcome:

Please see the attached code.

I have also make the entries on the /root/.bash_profile:

export ANT_HOME=/usr/local/apache-ant-1.7.0
export JAVA_HOME=/usr/local/jdk1.6.0_07
export PATH=$ANT_HOME/bin:$JAVA_HOME/bin:$PATH

I am also attaching the .bash_profile.

Thanks a million.
echo $ANT_HOME

/usr/local/apache-ant-1.7.0
 

echo $JAVA_HOME

/usr/local/jdk1.6.0_07
 

echo $PATH

/usr/local/apache-ant-1.7.0/bin:/usr/local/jdk1.6.0_07/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
 

java -version

java version "1.6.0_07"

Java(TM) SE Runtime Environment (build 1.6.0_07-b06)

Java HotSpot(TM) Server VM (build 10.0-b23, mixed mode)
 

ant -version

/usr/bin/build-classpath: error: Could not find xml-commons-apis Java extension for this JVM

/usr/bin/build-classpath: error: Some specified jars were not found

Apache Ant version 1.6.5 compiled on January 6 2007

Open in new window

.bash-profile.txt
0
 
LVL 2

Expert Comment

by:rsneale
ID: 22714446
Ok,  turning another corner, the obvious.   What is happening here is you do not have the xml-commons-apis installed, I think.   Do this:

      yum list xml-commons-apis

I think it will return: Error: No matching Packages to list

Now do this:

      yum install xml-commons-apis

This should install the packages.

Now try the ant -version or the ant build.xml suggested earlier.


0
 

Author Comment

by:combustion007
ID: 22715514
Hello rsneale,

you were right, none of the xml-commons-apis were installed. I followed on with your instructions and this is what I have:

ant -version returns:

Apache Ant version 1.6.5 compiled on January 6 2007

0
 
LVL 2

Expert Comment

by:rsneale
ID: 22715671
I guess we be done then.   I am very sorry if this was a laborious path and I hope that there was some meaningful information imparted.    A couple of closing comments:

1)   I would move off root as soon as you can.   I do not know if this is your standard operating procedures but I would not live there.

2)  On the initial question you  indicated that it was ant 1.7.0 you were attempting to install buy your last indicated 1.6.5.   I would suggest going to 1.7.1 because it is a bug fix of 1.7.0 and 1.6.5 has some serious memory leaks (permgen).

Have fun and keep going, it gets easier but never easy.

Rich
rsneale at gmail dot com
0
 

Author Comment

by:combustion007
ID: 22715826
Hello Rich,

I just wanted to run it by you this. I just did java -version, and it is gone back to 1.4.2. is this normal?

Thanks a lot.
0
 
LVL 2

Expert Comment

by:rsneale
ID: 22716034
Check your PATH.  It is a good chance that you have lost your definitions of JAVA_HOME, ANT_HOME and PATH.   Not being there, I do not know if you had logged off or started a new shell or   the state of .bash_profile or .bashrc definitions.    Just doing the exports as mentioned earlier will bring it back.   Bet that is why you also saw 1.6.5 vs the 1.7.0 of ant.  Many times, because I switch environments frequently,   I will create a setenv.sh with the exports and source the file to change what is set.   Remember, sourcing means adding, at the command line, a dot space and file to execute as:

 .  ./setenv.sh

This executes the exports in your current shell and the echo statements mentioned earlier should show the definitions.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org (http://seleniumhq.org) Go to that link and select download selenium in the right hand columnThat will then direct you to their downlo…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now