简体   繁体   中英

Jenkins : System.out.println is not printing anything on console window

I am new to jenkins. I have created a demo hello world print java file with following code :

public class Hello{
public static void main(String args[]){
System.out.println("Hello World");
}
}

Saved this file in Jenkins workspace folder. When I build this file using jenkins then on command line i am getting following output :

C:\.jenkins\workspace\first_project>javac Hello.java 

C:\.jenkins\workspace\first_project>exit 0 
Finished: SUCCESS

But in this console window there is nowhere text as 'Hello World'. Please help me out how can I print this on console window. Thanks in advance.

javac Hello.java means compile the program, not run it. You probably want to run it afterwards, eg through a shell-command?

Jenkins redirects output to per-job logs. In this manner, such output can be differentiated from other jobs, otherwise the output of jobs running in parallel would be very difficult to decipher.

Look at the output for your job in the Jenkins UI, you should find what you are looking for. Locating build output from Jenkins covers this as well.

Using

System.out.println("Hello World");

Is a bad practice, consider using slf4j or any other logging library Logs with slf4j looked good on Jenkins on any project I worked on. Create a logger

private static final Logger LOG = LoggerFactory.getLogger(LoggableClass.class);

And log with the severity you need

LOG.debug("The message");

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM