0

anyBody please share the knowledge.

i am facing this Exception

java.lang.ClassNotFoundException

from this project A

package com.demo.feed;
@WebServlet("/run")
public class ProjA {
  String[] args={};
  new com.om.demo.ProjB().main(args);
}

i have to call main method of maven Project B

package com.om.demo;
public class ProjB {
    public void main( String[] args )
    {
        hello();
    }
    static void hello() {
            System.out.println("some text");
        }

}

I tried these things adding project B to project A and after that on run configuration i have added classPath Variables..

Needed output in console : some text

Psidom
  • 209,562
  • 33
  • 339
  • 356
John Adam
  • 29
  • 7

2 Answers2

0

In the pom of Project A you will have to add Project B as a dependency and then try running. Before running you should make sure to run mvn clean install on Project B

0

In pom.xml in dependencies section of project which contains ProjA class, you have to put:

    <dependency>
        <groupId>com.om.demo</groupId>
        <artifactId>projb</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>

where projb is project which contains class ProjB. And then do mvn install on project which contains ProjB class.

user5927256
  • 51
  • 1
  • 1
  • 5