How to compile and run a simple java file in jenkins on Windows

I installed Jenkins on Windows and created a job in Jenkins. I want to compile and execute a simple java file (say Hello.java). How can i do this?

My Hello.java contains the following code:

public class Hello { public static void main(String args[]){ System.out.println("I'm dancing"); } } 
+6
source share
2 answers
  • Go to the configuration page of your work / project
  • Choose the Run Windows Batch Command command from the Add Build Step command
  • Enter the following into the Command field: javac Hello.java java Hello
  • Save configuration
  • Store the Hello.java file in the / Jenkins / workspace / folder
  • Create a project / task by clicking the Create Now link and view the console output.
+10
source

Take a look at Maven for automatic builds on a continuous integration server such as Jenkins: http://www.sonatype.com/books/mvnref-book/reference/public-book.html

There is even an exec plugin that allows you to run a Java program using Maven, but this is rarely necessary on a continuous integration server.

0
source

All Articles