javamavenpom.xmlnexus

Unable to create an object of the class from Maven type project


My pom.xml has only 1 dependency -

<dependency>
    <groupId>com.shubham.TestNexus</groupId>
    <artifactId>TestNexus</artifactId>
    <version>1.0</version>
</dependency>

This is a test jar that I have created and uploaded to my local nexus repository. I could see that when I am building the project, maven is downloading the jar and placing it in the Maven Dependencies directory. I could see the same jar added to the classpath as well.

This jar has nothing but a simple helloWorld printing method.

Now when I am using this jar in my project, it is not allowing me to create the object of the class inside this jar.

And, when I tried making a non-maven java project and added the jar manually to the classpath I am able to create the object of the class. Can anyone please help here.


Solution

  • I found the solution to the problem, seems like it doesn't allow the jars that have classes, present in the default package. I created another jar and put it inside a package and it worked. Thanks a lot everyone.