5

when I'm trying to clean/install maven following error I'm facing... any suggestions Error: Could not find or load main class Pictures.spring-tool-suite-3.7.1.RELEASE-e4.5.1-win32-x86_64.sts-bundle.sts-3.7.1.RELEASE.configuration.org.eclipse.osgi.24.0..cp.;.D:.Saved

UmaShankar
  • 221
  • 5
  • 14

4 Answers4

4

Two ways:

  1. below setting is tested in intellij IDE:
    edit configuration->Configuration->Main class: specify fully qualified path.
  2. you can specify main class through maven plugin in your pom.xml like below:.
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <archive>
            <manifest>
              <addClasspath>true</addClasspath>
              <mainClass>fully.qualified.MainClass</mainClass>
            </manifest>
          </archive>
        </configuration>
      </plugin>
    </plugins>
  </build>
Tulika
  • 128
  • 8
0

Can you share your project structure and type ? Is it a spring boot Application ?

Alternatively, you can set you Main class / Main type from IDE

Right click on project -> Run as -> Run configurations -> Add main type or main class here 
Harsh
  • 812
  • 1
  • 10
  • 23
  • it's Jersey restful webservers – UmaShankar Feb 01 '22 at 09:28
  • Not sure I have worked on that area ! however from the error it's clear that it is not able to find and hence load the main class. Check your project structure if any alignment helps – Harsh Feb 01 '22 at 09:41
  • I dont find to add main class post clicking on Run Configurations... can you please tell me what I need to open after Run configuration – UmaShankar Feb 01 '22 at 13:10
0

Can you try to change line in .classpath

<classpathentry kind="lib" path="C:/Users/ABC/Projects/last.fm-bindings-0.1.1.jar" sourcepath=""/>

Like:

<classpathentry kind="lib" path="last.fm-bindings-0.1.1.jar"/>
Halil Sahin
  • 568
  • 1
  • 6
  • 25
0

Add the following code snippet to your maven build file and be sure to replace fully.qualified.MainClass with the main class in your application.

<build>
  <plugins>
    <plugin>
      <artifactId>maven-assembly-plugin</artifactId>
      <configuration>
        <archive>
          <manifest>
            <mainClass>fully.qualified.MainClass</mainClass>
          </manifest>
        </archive>
        <descriptorRefs>
          <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
      </configuration>
      <executions>
        <execution>
          <id>make-assembly</id>
          <phase>package</phase>
          <goals>
            <goal>single</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

You can then use mvn clean compile assembly:single to generate an executable jar which can be run without issues.

Further Reading: https://stackoverflow.com/a/574650/15806017

stefano
  • 336
  • 2
  • 8