Execute Jar File Using Ant

Posted : adminOn 6/3/2018
Ubuntu Execute Jar File

In this example you will see how to structure the project. If the grows bigger, it will become a problem to manages the files if all the files are there in the same directory. For a easier maintenanace all the source file should be kept in the src directory, the compressed jar file should be kept in the dist directory and all the intermediate class files should be kept in the build/classes directory. Azax Syndrom Discography here. By imposing structure cleaning the project becomes easy, we can just delete the directory and recreate it. Using the task we create build/classes and dist directory. During the compilation process all the java files in the src directory will be compiled and the generated class files will be placed in the build/classes directory. Since we placed all the class files under the build/classes directory, creating jar file becomes easier, you can simply specify the basedir attribute as ' build/classes' instead of specifying basedir='.'

And includes='*.class'. After creating the jar file we place it in the dist directory ( destfile='dist/HelloWorld.jar'). You can use the java task to execute a class file as shown below.

Avanti Italian Textbook Pdf. The classname attribute refers to the java class to be executed and the classpath attribute refers to the directory in which the class is located. Since all the class files and jar files are isolated, we can easily clean the project by deleting the respective directories. The default target is compress, so when you run the build file the compress target will be executed. The compress target depends on compile target which in turn depends on the init target, so first the init target will be executed and the two directories will be created, then the compile target will be execute, later the jar file is created. When you run the ' ant execute' command the execute target will be invoked.