'"Cannot find symbol" error when creating an instance of an object

I'm new to using maven and have a Project where I'm trying to create an instance of an object but keep getting the error:

error: cannot find symbol
        CommentProcessor p = new CommentProcessor();
        ^
  symbol:   class CommentProcessor
  location: class App

I have the files:

App.java

package com.group.pack;

public class App {

  public static void main(String[] args) {

    CommentProcessor p = new CommentProcessor();
    p.connect();

   }
}

CommentProcessor.java

package com.group.pack;

public class CommentProcessor {

  public CommentProcessor(){

  }

  public void connect(){
    ...
  }

}

App.java and commentProcessor.java are both in src/main/java/com.group/pack

If i take the files out into a separate project without the package (and not using maven), it will compile without any issues. Would this be something to do with how maven works? Ive also tried creating a jar file, but this won't work either.

This is the pom that VSCode generated:

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

  <!-- The Basics -->
  <groupId>com.group.pack</groupId>
  <artifactId>pack</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>pack</name>
  <url>http://maven.apache.org</url>

  <properties>
    <maven.compiler.release>11</maven.compiler.release>
  </properties>

  <dependencies>
    <!-- https://mvnrepository.com/artifact/junit/junit -->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

<!-- Build Settings -->
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.8.1</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
</project>


Solution 1:[1]

I've recreated a mock project, I see no issues for me. Try recreating a simple mock project.

note:

I've noticed a problem in your pom.xml file. When you create a jar file, you will need to create a jar with the dependencies

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 inspectorconfusion