[HELP] Java - Build and Packaging Lab

I am doing “APPLICATIONS BASICS, LABS – JAVA – BUILD & PACKAGING” in “DevOps Pre-Requisite Course”. In the 10th question, the hint is java -cp /opt/maven/my-app/target/my-app-1.0-SNAPSHOT.jar com.mycompany.app.App, I don’t understand where com.mycompany.app.App come from. Why it have .App in the end.

When I researched, I could only find a few commands with a structure similar to java -cp <classpath> <classname> [<arguments>]

Example:
$ java -cp JarExample2.jar com.baeldung.jarArguments.JarExample "arg 1" arg2@

The <classname> don’t have .app part.

With regard to the class name:

  • com.mycompany.app.App:
    • com.mycompany.app is the package name.
    • App is the class name within that package.

Java uses packages to organise classes. A fully qualified class name in Java includes its package prefix, which helps avoid naming conflicts between classes from different sources. For instance, multiple vendors can have a class named App, but as long as they’re in different packages, they won’t conflict.

In your research, the example com.baeldung.jarArguments.JarExample similarly includes a package name (com.baeldung.jarArguments) and a class name (JarExample). It does not have .app because .app is not a required suffix—it is simply part of the class name in your specific course example.

The .App in your example is just the chosen name for the class. It could be anything. It does not denote any special type.

1 Like

Thank you so much, sir