Did you just now install Jenkins from "https://www.jenkins.io/doc/book/installing/windows/" using Windows MSI Installer? After the installation is finished, you browse the Windows Services to check if it is running (In case you are wondering how to do this, open "Control Panel\System and Security\Administrative Tools" in File explorer, double-click on Services and locate Jenkins within the services).
Wait, what? The Jenkins did not start running after Installation. Never Mind, you try to start it manually. But, it gives you this error message:
Let's try to troubleshoot this. Go to the folder where Jenkins is installed. In my case, it is "C:\Program Files\Jenkins". Open the "jenkins.err" file in a text editor. You would see something like this -
Oh, wait, You can't run Jenkins with the Java version installed on your machine. The obvious solution is to install the supported Java version and then run Jenkins. But, here, I would walk you through the steps, following which, you can run Jenkins with Java 17. Now, there are two ways to do this.
First approach is to use the command prompt. Open Command prompt and go to the directory where Jenkins is installed.
C:\>cd C:\Program Files\Jenkins
There is a file named "jenkins.war" within this directory. Next, run the Jenkins, by giving the following command -
C:\Program Files\Jenkins>java -jar jenkins.war --enable-future-java
Here, the option --enable-future-java, is used to start Jenkins with Java 17.
As you can see, Jenkins is now up and running. Next, you can open your browser and go to http://localhost:8080 or the port number that you provided for Jenkins. If this is the first time you are running Jenkins, wait for the "Unlock Jenkins" screen and follow the steps.
Now, what if you want to run Jenkins as a Windows service and not through the command prompt. Next, I will walk you through the steps to run Jenkins as a Windows service with Java 17.
Open File Explorer and go to the folder where Jenkins is installed - "C:\Program Files\Jenkins".
Open the XML document named "jenkins" in a text editor.
Locate the tag <arguments> within this XML document.
Add the option --enable-future-java within the tag <arguments> right after, -jar "C:\Program Files\Jenkins\jenkins.war"
Now, go back to "Control Panel\System and Security\Administrative Tools" in File explorer, double-click on Services and select Jenkins within the services. Click on "Start the Service" in the left panel.
Voila, Jenkins is now running. Again, open your browser, go to http://localhost:8080, and you are good to start working on your CI/CD using Jenkins with Java 17 on Windows 10.
References:
https://www.jenkins.io/doc/