How to compile and run a simple java program in Jenkins

1. Before you run and compile the code you have already installed java on your system, by default Jenkins environment setups like the path of java, Then Write a java class and placed on your desired location then run the Jenkins, by default Jenkins run on 8080 port. go to https://localhost:8080 then follow the below steps to compile and execute the java class in Jenkins.
Jenkins Login Page
2. After logging into the Jenkins, Jenkins dashboard should be like below.
Dashboard
3. Go to the Jenkins dashboard and Click on New Item
Dashboard of Jenkins
4. In the next screen, enter the Item name, in this case, I have named it java. Choose the ‘Freestyle project option.
Project Dashboard
5. The following screen will come up in which you can specify the Description of the job. 
Description
6. We need to specify the location of files which need to be built. In this example, I used the custom workspace to specify the java class location.
Location of project
7. Now go to the Build section and click on Add build step → Execute Windows batch command. In the command window, enter the following commands javac Helloworld.java java HelloWorld
Then click on the save button.
Build step
8. Once saved, you can click on the Build Now option to see if you have successfully defined the job.
Job dashboard
9. Once the build is completed, a status of the build will show if the build was successful or not. In my case, the following build has been executed successfully. Click on the #1 in the Build history to bring up the details of the build.
Build output

SUBSCRIBE TO OUR NEWSLETTER

I’m the Founder of quickdevops.com. I am a Professional Blogger, Application developer, YouTuber. I’ve been blogging since 2015.I spend a lot of time learning new techniques and actively help other people learn web development through a variety of help groups and writing web development tutorials for my website and blog about advancements in web design and development.Besides programming I love spending time with friends and family and can often be found together going out catching the latest movie or planning a trip to someplace I've never been before.

0 Response to "How to compile and run a simple java program in Jenkins"

Post a Comment