I am a complete noob in java and I want to know how do you run a java program after you use build.xml. I am using 'cmd' and I got the message BUILD SUCCESSFUL after compiling (?) Now what should I do to run the program ?
Sorry If I am not allowed to post this type of question. I couldn't find any rules.
Thanks in advance :)
Edit: it created a .war file. how do I execute it ?
I assume that this is a simple "Hello, World" Java program ( HelloWorld.java ) and that the HelloWorld.java , build.xml and the HelloWorld.class (to be generated) are in the current directory ( . )
HelloWorld.java file :
public class HelloWorld {
public static void main(String[] args) {
// Prints "Hello, World" to the terminal window.
System.out.println("Hello, World");
}
}
Create two targets : compile and run in your build.xml file :
<project name="Hello World" basedir=".">
<target name="compile">
<javac srcdir="." includeantruntime="true" includes="HelloWorld.java" destdir="."></javac>
</target>
<target name="run" depends="compile">
<java classname="HelloWorld" fork="true"></java>
</target>
</project>
Now you simply need to navigate to the current directory in your terminal and run :
ant run
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.