Reputation: 887
I am using 'jenkins-client-0.20.jar' and programming in java to connect to Jenkins and extract few information like list of jobs, nodes, active nodes, projects etc. I wrote below piece of code by referring "https://github.com/jenkinsci/java-client-api" link. On compiling I am getting error as below
import com.offbytwo.jenkins.*;
import com.offbytwo.jenkins.client.*;
import com.offbytwo.jenkins.model.*;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Map;
public class NewTest {
public static void main(String[] args) throws URISyntaxException, IOException {
JenkinsServer server = new JenkinsServer(new URI("https://my-jenkins.abc.com/jenkins/"), "admin", "admin");
Map<String, Job> jobs = server.getJobs();
for (Map.Entry<String, Job> entry : jobs.entrySet())
{
System.out.println(entry);
}
}
}
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Function
at NewTest.main(NewTest.java:13)
Caused by: java.lang.ClassNotFoundException: com.google.common.base.Function
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
I have following jars in my eclipse.
How do I fix this? Thank you
Upvotes: 0
Views: 2096
Reputation: 69505
Add the google-collections-1.0.jar
to your classpath. This contains the class com.google.common.base.Function
BTW: This Project is a maven projekt. So oyu should use maven to build your Project
Upvotes: 3