'Dockerfile after build container doesn't work ''Could not find or load main class''

Yoo Coders! have one issue with docker, when i create container and after build it,i want run him,but have this Error

Error: Could not find or load main class Go
2022-02-18T19:52:59.856728094Z Caused by: java.lang.ClassNotFoundException: Go

** class Go**

package sk.wynny;

public class Go {
    public static void main(String[] args) {
        System.out.println("YOOOO bro!");
    }
}

Dockerfile

FROM openjdk:17.0.1
RUN mkdir /app

COPY out/production/ /app

WORKDIR /app

CMD  java Go

enter image description here



Solution 1:[1]

The fully qualified name of your class is sk.wynny.Go and to run, you need to tell Java what is the current directory or your class with the --classpath option.

FROM openjdk:17.0.1
RUN mkdir /app

COPY out/production/ /app

WORKDIR /app

CMD  java -classpath /app sk.wynny.Go

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 Harry Coder