Using Eclipse, how can i tell what version of ANT is being used? - eclipse

Same as original question, using Eclipse, how can i tell what version of ANT it is configured to use?

In Eclipse Helios:
Open the Preferences dialog (Window -> Preferences)
Navigate to the Ant -> Runtime page
Expand the Ant Home Entries node on the Classpath tab
This shows the path used for Ant classpath, which also reveals ANT_HOME for Eclipse.
So by default in Helios you will have something like:
<ECLIPSE_ROOT>/plugins/org.apache.ant_1.7.1.v20100518-1145\lib\ant.jar
etc
On this same page, you can also change ANT_HOME to use a different version of Ant you have installed on your PC.

Create a build file and echo $ant.version
On Helios
create an empty build.xml
ctrl+space in the empty file and select the default build file template with 2 targets
in the target called "default" add <echo>${ant.version}</echo>
save the file
right click on the build.xml in the navigator
select run as ant build

In Eclipse Helios (version 3.6.2) the version of the various plug-in modules such as ANT can be determined in the following manner.
Select the Help -> "About Eclipse SDK" menu option
Click on the "Installation Details" button
Click on the "Plug-ins" Tab
The "Plug-in Name" column is where ANT can be found the version is in the next column.
There will probably be multiple references to ANT in the "Plug-in Name" column including
Ant Build Tool Core
Ant Launching support
Ant UI
Apache Ant
I believe the "Apache Ant" is the most relevant entry and the others deal with how ant integrates with eclipse.

Related

How to Run/Debug a Ant Project in directly in tomcat through Eclipse?

In this project ....
Web.xml is located under Project Folder > web > Web-INF > web.xml
This project is already created by or clients and we are maintaining it.
Actually we do the build using the build.xml script using ant, it will generate a app.war then we will deploy it in tomcat to run.
In the above process there is no way i can debug the code.
More info:
This is not a struts project, it is Spring MVC project
Why don't you add Ant plugin to eclipe and run it through eclipse?
Help: How to run ant project in eclipse
Running Ant buildfiles
To run an Ant buildfile in the Workbench:
In one of the navigation views, select an XML file.
From the file's pop-up menu, select Run Ant.... The launch
configuration dialog
opens.
Select one or more targets from the Targets tab. The order in
which you select the items is the order in which they will run. The
order is displayed in the Target execution order box at the bottom
of the tab. You can change the order of the targets by clicking the
Order... button.
(Optional) Configure options on the other tabs. For
example, on the Main tab, type any required arguments in the
Arguments field.
Click Run.
or Check this answer
Want an eclipse java project to run ant build files automatically

Run as Ant build' Missing in my eclipse

I am unable to right click and run my build.xml file by choosing 'Run as Ant' . Whenever I click it says run configuration and that goes into running Java file options .
This works for me.
Go to..
1. Help -> Install New SoftWare
Work With -> "http://download.eclipse.org/releases/juno"
Drop down list "General Purpose Tools"
select "Eclipse Plug-in Development Environment"
After doing this...eclipse started showing option of Ant Build in Run as
In Eclipse Neon, the Ant Build moved to Run > External Tools > External Tools Configurations ... it is not located in the default Run anymore.
An example of a build xml file and how to run it
I hope this helps!
I encountered a configuration where depending on the filename of build.xml file the "Run As" menu did not contain the "Ant Build" and "Ant Build..." commands. The commands "Ant Build" and "Ant Build..." (see the image in ricardoramos's answer) are present if the build file is named build.xml, but absent if the file is named build-something.xml.
I tracked down that the cause of this issue in my configuration was plugin LiClipseText. Uninstalling the plugin resolved the issue. I observed this with LiClipseText version 2.1.2 and with Eclipse versions "2018-09" (4.9), "Photon" (4.8) for Java EE Developers.
The plugin provides its own editor for XML files, and I guess that interferes with the way how Eclipse detects that an XML file is an Ant build file.
It may be that this will be fixed in a future version of LiClipseText.
For a recipe on how to uninstall the plugin - see question 6174725. For a cleanup afterwards - see question 221476.
Another possibility is your build.xml file is not parseable by ant
For example, if you open the Ant Perspective (Open Perspective | Other | ant) and then choose the Add Buildfiles toolbar button, then choose your build.xml file, if it is not a valid build file, you may see an error message "Unable to parse as an ant build file".
Once you fix your build.xml file, the Run As ant RMB command on the build.xml file will appear.
(above was my experience on Eclipse Mars.2)
Follow the below steps.
Go to Windows -> Preferences -> General -> Content Types -> Text -> XML -> Ant BuildFile.
Just click on Add button and add your AntBuild file. click ok.
Restart your Eclipse.
Follow the below steps.
Go to Windows -> Preferences -> General -> Content Types -> Text -> XML -> Ant BuildFile.
Just click on Add button and add your AntBuild file. click ok.
Workaround:
Open the ANT-View, add the build file and start it from there.
(Had the problem in JBDS8 after installing IBM Diagnostics Tools)

Tools jar does not exist Eclipse JAVA

The archive: C:/Java/jdk1.6.0_26-32/lib/tools.jar which is referenced by the classpath, does not exist.
This is the error I have when run Tomcat. There was no problem cleaning or publishing - only when i start the Tomcat server.
Now, I checked my folders and there is a tools.jar in file path C:\Java\jdk1.6.0_34\lib
What am i missing?
using jre6 and have jdk1.6.0_34 installed
I found this question trying to build my project using Ant in Eclipse, and I would get the same error message as above. The suggestions in #Parth's and other answers to edit the Installed JREs is the first step. What I also needed to run Ant successfully was
Right click on build.xml, select "Run As", select "Ant Build..." (note the ...)
Click on the JRE tab
Change the Runtime JRE to the same thing that you updated in the first stage, and press Apply. (That is, the runtime JRE as you specified by "Preferences" -> "Java" -> "Installed JREs", as in #Parth's answer.)
Otherwise it seems that Ant will still try to build with the old JRE that doesn't have tools.jar. Hope this helps someone.
Right click on your eclipse project, In Preferences go to Java > Installed JREs, select your JDK and click on Edit. In the new Dialog you can add external jars like tools.jar to your execution environment.
I found the solution to resolve this.
Go to Run Configurations > classpath and under User Enteries you will have tools.jar and its path would be pointing to the old folder. Remove that and click on "Add External Jars" to add the tools.jar from the new path. And that is it.
This worked for me on Eclipse:
Windows -> Preferences -> Select Java -> Select Installed JREs -> Add
-> Add your JDK -> Establish it as default -> Apply -> OK.
After this, I've to establish project related settings too:
Right click on your Project Name (in Project explorer ) -> Properties ->
Java Build Path -> Click on JRE System Libraries -> Edit ->
Select Workspace Default JRE (jdk included above)
Check your "run configurations" (Eclipse Menu Run -> Run Configurations ....) also, since therein the classpath may be wrong or has gotten obsolete.
Tomcat needs a full JDK/SDK to run but under C:/Java/jdk1.6.0_26-32/, you only have a JRE installed.
Cleaning and deploying is done by Eclipse, no Tomcat code is involved so this works.
You need to configure your environment so that Tomcat uses C:\Java\jdk1.6.0_34 as Java VM. Check the values of JAVA_HOME and the content of setenv.bat
Right click on project->Properties->Compiler->Configure workspace settings->go to configure->installed jre->give jdk path
In my case with using ANT build I had to change the setting
Add tools.jar in the below location.
Windows --> Preferences --> Ant --> Runtime --> Global Entries.
In my case the Tomcat server in Eclipse has been created under older JDK (just a few builds). My solution was to remove the sever and add it again (now using current JDK).
I had the same problem (I can reproduce it) and my solution sounds like the integration in Eclipse is really screwed up but I actually fixed it by starting Eclipse with the same JDK version.
Add/edit the following in your eclipse.ini (which is in the Eclipse directory):
-vm
path/to/jdk/bin
Where path/to/jdk/bin is the path to the JDK bin directory of the version you are using for ant/tomcat.
Note that tools.jar is NOT included in a JRE distribution.
If you are running Ant build file and getting this error in eclipse, then your eclipse is configured to use two differently named JRE's. i.e. One from the jre folder and another jre from inside the jdk's folder. Adding tools.jar may be a workaround but I used the JRE inside the JDK's folder(C:\Program Files\Java\jdk1.8.0_121). Inorder to change this,
Check in Installed JRE section which JRE is cheked(I had jdk1.8.0_121 checked and jre1.8.0_121 left unchecked).
Update your eclipse classpath by navigating to Window > Preferences > Java > Installed JRE > Execution Environments.
Now select the JavaSE-1.x on the left side and select the compatible JRE[perfect match]. Select the same JRE(jdk1.8.0_121) you had it checked above and click Ok. Optionally you can delete the JRE(jre1.8.0_121) which is unused to avoid confusion if it is not used in any other projects.
Now your project will build and you can run the Ant build files. Check the image below.
Try to add the tools.jar as an external JAR.
For eclipse,
Right click the project name and select Properties
Go to Java "Build Path"
Select tab "Libraries"
Click "Add External JARs"
Select the relevant .jar file from the file selection
I am not sure it applies to all situations, but if you right click Ant script and there is an item "External tools configuration" under "Run as" menu, select it, and go to JRE tab. As far as I can say, it may be configured independently from your project and point to the JRE, not JDK, in which case there would be missing tools.jar
I remove server (Tomcat 6.0) from window -> preferences -> server -> Runtime environment.
And add again. Then, I add my project to server again. The problem is destroyed.
If You are getting this error while running the ANT build then follow the below steps.
In the Eclipse go-to window-> preferences-> ANT-> RUNTIME
then select classpath tab then select Global Entries and add tools.jar as an external jar.
Run the ANT build.

How do i configure eclipse to make use of different version of JDK

I have three project running on eclipse i want to use JDK 1.4 for two project and JDK 1.6 for third project how do i do that?
You need:
first to declare the different JRE in your Eclipse: See "Eclipse - no Java (JRE) / (JDK) … no virtual machine…"
then to add the right JRE in your project settings (see this blog post for instance)
The default JRE is shown with a check mark and is used by new eclipse projects unless the project specifically overrides the value.
So the next step is to check which JRE the current project is using.
Right click the project and choose "properties".
Select "Java Build Path" and then click the tab labeled "Libraries". You should see an entry like "JRE System Library [version]".
To change the JRE version,
highlight the entry and click "Remove".
Then click "Add Library...". Choose "JRE System Library".
If you choose "Workspace Default", the project will use the JRe defined under "Windows -> Properties" as explained above.
You may also specify an alternate JRE located somewhere on your file system, or choose an embedded execution environment provided by Eclipse.
you can configure VM in eclipse.ini file.

Eclipse Generated Build Files

I am using the ZK Studio plugin to create a web based project based on the ZK framework. Now, in order to deploy this project, all I do is right click on the project and select "Export" then select "WAR file". However, I would like build files to be created so that someone else can just make a change and run the build file to re-compile and create the WAR file automatically. I have been told that Netbeans does this automatically, and it seems so does eclipse since it allows me to just say "Export as WAR". However, I need to commit build files to the svn as well. How can I get this option through eclipse?
Thanks!
P.S. I have seen this question:
Generating Ant build file for a project in eclipse
But I do not have that option when I right click for some reason.
Select build.properties file in project explorer view and from context menu (right click) select PDE Tools -> Create ant build file.
Same can be achieved through an ant task as well. See http://help.eclipse.org/helios/index.jsp?nav=/4_2_0