<p>I've tried to reproduce the <a href="https://github.com/kubernetes-client/java/blob/master/examples/src/main/java/io/kubernetes/client/examples/Example.java" rel="nofollow noreferrer">example in k8s-java</a> in my mini-maven project.
However, I kept getting into this error - Exception in thread &quot;main&quot; java.lang.NoClassDefFoundError: io/kubernetes/client/openapi/ApiException.
My maven project is borrowed from <a href="https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html" rel="nofollow noreferrer">maven in 5 minutes</a> and is only changed a few lines.</p>
<ul>
<li>App.java</li>
</ul>
<pre class="lang-java prettyprint-override"><code>package com.mycompany.app;

import io.kubernetes.client.openapi.ApiClient;
import io.kubernetes.client.openapi.ApiException;
import io.kubernetes.client.openapi.Configuration;
import io.kubernetes.client.openapi.apis.CoreV1Api;
import io.kubernetes.client.openapi.models.V1Pod;
import io.kubernetes.client.openapi.models.V1PodList;
import io.kubernetes.client.util.Config;
import java.io.IOException;


/**
 * A simple example of how to use the Java API
 *
 * &lt;p&gt;Easiest way to run this: mvn exec:java
 * -Dexec.mainClass=&quot;io.kubernetes.client.examples.Example&quot;
 *
 * &lt;p&gt;From inside $REPO_DIR/examples
 */
public class App {
    public static void main(String[] args) throws IOException, ApiException {
      ApiClient client = Config.defaultClient();
      Configuration.setDefaultApiClient(client);
  
      CoreV1Api api = new CoreV1Api();
      V1PodList list =
          api.listPodForAllNamespaces(null, null, null, null, null, null, null, null, null);
      for (V1Pod item : list.getItems()) {
        System.out.println(item.getMetadata().getName());
      }
    }
  }

</code></pre>
<ul>
<li>pom.xml</li>
</ul>
<pre class="lang-xml prettyprint-override"><code> &lt;dependencies&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;junit&lt;/groupId&gt;
      &lt;artifactId&gt;junit&lt;/artifactId&gt;
      &lt;version&gt;4.11&lt;/version&gt;
      &lt;scope&gt;test&lt;/scope&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;io.kubernetes&lt;/groupId&gt;
      &lt;artifactId&gt;client-java&lt;/artifactId&gt;
      &lt;version&gt;10.0.0&lt;/version&gt;
    &lt;/dependency&gt;
  &lt;/dependencies&gt;
</code></pre>
<ul>
<li>Commands</li>
</ul>
<ol>
<li><code>mvn clean package</code></li>
<li><code>java -cp target/my-app-1.0-SNAPSHOT.jar com.mycompany.app.App</code></li>
</ol>
<ul>
<li>Errors</li>
</ul>
<pre><code>Error: A JNI error has occurred, please check your installation and try again
Exception in thread &quot;main&quot; java.lang.NoClassDefFoundError: io/kubernetes/client/openapi/ApiException
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
        at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
        at java.lang.Class.getMethod0(Class.java:3018)
        at java.lang.Class.getMethod(Class.java:1784)
        at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:650)
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:632)
Caused by: java.lang.ClassNotFoundException: io.kubernetes.client.openapi.ApiException
        at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
        ... 7 more
</code></pre>
<p>Thanks anyone for the help!</p>

<p>run using <code>mvn exec:java -D exec.mainClass=com.mycompany.app.App</code></p>
