getting error in testng java lang NoClassDefFoundError com google common collect ImmutableMap

+1 vote
getting this error

java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableMap

here is the code:

package testngpkg;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

import org.testng.annotations.Test;

public class firstclass {
 WebDriver driver;
 
  @Test
  public void browser() {
   driver = new ChromeDriver();
   driver.get("http://newtours.demoaut.com/");
  
  }
}
Feb 14, 2020 in Selenium by Aarti
• 130 points
6,734 views
Do u have the Guava libraries imported in your classpath?

1 answer to this question.

0 votes

A NoClassDefFoundError is thrown when the JRE can't find a class. In your case, it can't find the class com.google.common.base.Function, which you most probably did not add to your classpath.

EDIT

After downloading the following libraries:

Selenium: http://code.google.com/p/selenium/downloads/list

Guava: http://code.google.com/p/guava-libraries/downloads/list

Apache HttpComponents: http://hc.apache.org/downloads.cgi

JSON jar: http://www.jarfinder.com/index.php/jars/versionInfo/21653

and unzipping them and putting all JAR files in a folder called lib, the test class:

answered Jun 3, 2020 by Ramesh
• 140 points
Hey @Ramesh thanks, buddy! but the JSON jar link isn't accessible.

Related Questions In Selenium

0 votes
1 answer
+1 vote
1 answer
0 votes
1 answer

Getting error while running a XML file in TestNG

Hello @Sradha, The synatx of using test is ...READ MORE

answered Dec 26, 2018 in Selenium by Rashmi
8,193 views
0 votes
0 answers
+1 vote
0 answers
0 votes
2 answers

TestNG error:- Cannot find class in classpath

The above link didn't work it means ...READ MORE

answered Feb 12, 2020 in Selenium by Rashmi Reddy PR
20,789 views
+1 vote
3 answers

java.lang.ClassNotFoundException: okhttp3.ConnectionPool - Selenium Error

The only reason for ClassNotFoundException is if ...READ MORE

answered Mar 30, 2018 in Selenium by nsv999
• 5,520 points
7,967 views