I created a new project to set Google Guava.
This is my POM.xml.
<dependencies>
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>20.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>InetAddressTest</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
This is my main method.
public static void main(String[] args) throws Exception {
try {
System.out.println(InetAddresses.isInetAddress("127.0.0.1"));
} catch (NoClassDefFoundError exp) {
System.out.println(exp);
}
}
I am able to run it inside my IDE.
I can package it with mvn package
When I run it java -jar target/<NAME>.jar
, it throws an exception java.lang.NoClassDefFoundError: com/google/common/net/InetAddresses
I tried to browse the solutions. But they haven't worked so far.
I am guessing (based on other problems) that I am missing some dependencies for Guava
?