{"id":5119,"date":"2018-12-08T15:18:28","date_gmt":"2018-12-08T15:18:28","guid":{"rendered":"https:\/\/www.testingdocs.com\/questions\/?p=5119"},"modified":"2021-03-20T09:11:19","modified_gmt":"2021-03-20T09:11:19","slug":"how-to-fix-the-error-unable-to-initialize-main-class-org-testng-remote-remotetestng","status":"publish","type":"post","link":"https:\/\/www.testingdocs.com\/questions\/how-to-fix-the-error-unable-to-initialize-main-class-org-testng-remote-remotetestng\/","title":{"rendered":"How to fix the Error Unable to initialize main class RemoteTestNG"},"content":{"rendered":"<p>When we try to run TestNG tests, we get the following exception. Unable to initialize main class org.testng.remote.RemoteTestNG<\/p>\n<h3>Error Trace<\/h3>\n<pre>Error: Unable to initialize main class \r\norg.testng.remote.RemoteTestNG \r\n        Caused by: java.lang.NoClassDefFoundError: org\/testng\/TestNGException\r\n\r\n\r\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5120\" src=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/TestNG-Exception.png\" alt=\"TestNG Exception\" width=\"1630\" height=\"984\" title=\"\" srcset=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/TestNG-Exception.png 1630w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/TestNG-Exception-300x181.png 300w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/TestNG-Exception-1024x618.png 1024w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/TestNG-Exception-768x464.png 768w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/TestNG-Exception-1536x927.png 1536w\" sizes=\"auto, (max-width: 1630px) 100vw, 1630px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h3>Root cause<\/h3>\n<p>TestNG library is not found in the classpath. The fix for the error depends on the environment on how the tests are run. If the error occurs while running tests in Eclipse IDE, add the TestNG library to the project build path.<\/p>\n<p>Right-click on the Package explorer choose, <strong>Build Path &gt;&gt; Configure Build Path&#8230;<\/strong><\/p>\n<p>In the <strong>Java Build Path<\/strong> screen, Select the <strong>Libraries<\/strong> tab, click on the <strong>Add Library&#8230;<\/strong> button.<\/p>\n<p>Choose <strong>TestNG<\/strong> and click on the Next button.<\/p>\n<p>Click on the<strong> Finish<\/strong> button and Apply the action to save the setting.<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5124\" src=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Add-Library.png\" alt=\"\" width=\"1721\" height=\"990\" title=\"\" srcset=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Add-Library.png 1721w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Add-Library-300x173.png 300w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Add-Library-1024x589.png 1024w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Add-Library-768x442.png 768w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Add-Library-1536x884.png 1536w\" sizes=\"auto, (max-width: 1721px) 100vw, 1721px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>This will add the TestNG to the project. Run the TestNG tests. This will solve the exception and tests would run successfully.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5127\" src=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Tests-run-success.png\" alt=\"TestNG Exception\" width=\"1677\" height=\"991\" title=\"\" srcset=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Tests-run-success.png 1677w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Tests-run-success-300x177.png 300w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Tests-run-success-1024x605.png 1024w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Tests-run-success-768x454.png 768w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Tests-run-success-1536x908.png 1536w\" sizes=\"auto, (max-width: 1677px) 100vw, 1677px\" \/><\/p>\n<p>&nbsp;<\/p>\n<!--themify_builder_content-->\n<div id=\"themify_builder_content-5119\" data-postid=\"5119\" class=\"themify_builder_content themify_builder_content-5119 themify_builder tf_clear\">\n    <\/div>\n<!--\/themify_builder_content-->\n","protected":false},"excerpt":{"rendered":"<p>When we try to run TestNG tests, we get the following exception. Unable to initialize main class org.testng.remote.RemoteTestNG Error Trace Error: Unable to initialize main class org.testng.remote.RemoteTestNG Caused by: java.lang.NoClassDefFoundError: org\/testng\/TestNGException &nbsp; Root cause TestNG library is not found in the classpath. The fix for the error depends on the environment on how the tests [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[185],"tags":[],"class_list":["post-5119","post","type-post","status-publish","format-standard","hentry","category-selenium","has-post-title","has-post-date","has-post-category","has-post-tag","has-post-comment","has-post-author",""],"_links":{"self":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/5119","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/comments?post=5119"}],"version-history":[{"count":5,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/5119\/revisions"}],"predecessor-version":[{"id":23742,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/5119\/revisions\/23742"}],"wp:attachment":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/media?parent=5119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/categories?post=5119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/tags?post=5119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}