Tutorials Navigation
Apache Ant Tutorial - Executing Java code
Tutorial Name: Apache Ant Tutorial - Executing Java code
Category: PC Tutorials
Submitted By: hoot
Date Added:
Comments: 0
Views: 284
Related Forum: PC Building Forum
Share:
You can use Ant to execute Java code. In the following example, the java class takes in an argument (administrator's email address) and sends out an email.
public class NotifyAdministrator {
public static void main(String[] args) {
String email = args[0];
notifyAdministratorviaEmail(email);
System.out.println("Administrator "+email+" has been notified");
}
public static void notifyAdministratorviaEmail(String email) {
//......
}
}
Here is a simple build that executes this java class.
<?xml version = "1.0"?>
<project name = "sample" basedir = "." default = "notify">
<target name = "notify">
<java fork = "true" failonerror = "yes" classname = "NotifyAdministrator">
<arg line = "[email protected]"/>
</java>
</target>
</project>
When the build is executed, it produces the following outcome
C:\>ant
Buildfile: C:\build.xml
notify: [java] Administrator admin @ test.com has been notified
BUILD SUCCESSFUL
Total time: 1 second
In this example, the java code does a simple thing - to send an email. We could have used the built in the Ant task to do that. However, now that you have got the idea, you can extend your build file to call the java code that performs complicated things, for example: encrypts your source code.
Ratings
Comments
Related Tutorials
- 01. Emulating Xbox 360 on PC for Running COD4 With Mods(3,500)
- 02. How to: Matrix Numbers | Batch File(1,908)
- 03. How to Password Protect Files on Windows(857)
- 04. How to play Socom 2/3/ and Combined Assault on PC(6,737)
- 05. Modern Warfare 2 Vac Ban Bypass Tutorial(6,147)
- 06. How to embed an image on TheTechGame(3,100)
- 07. [PC] NIOH 2 OTHER USER SAVE RESIGN(13,004)
- 08. Host bot lobbies! Full Tutorial!(11,294)
- 09. Unban yourself [Plutonium BO2](14,243)
- 10. Fall Guys - How to Change Your Name Color on Fall Guys(8,390)
- 11. Best Crosshair Settings for Valorant(6,529)
- 12. Othercide The Surgeon Boss Guide(2,544)
- 13. Othercide Remembrances Unlock Guide(4,470)
- 14. Othercide Beginners Tips and Tricks(2,712)
- 15. How to Fix Grounded Crashes, Loading Time, Low FPS and Other(4,848)
"Apache Ant Tutorial - Executing Java code" :: Login/Create an Account :: 0 comments