I have created a simple Eclipse project having Main class inside src/com/docker/Main.java. When i try to run it inside a docker container after building the image, i get the Could not find or load main class error.
Docker image content:
FROM openjdk:8
COPY . /app/
WORKDIR /app
RUN javac src/com/docker/Main.java
CMD ["java", "com.docker.Main"]
I tried several variations of RUN and CMD but nothing worked. I tried with slashes '/' but still did not worked.
CMD ["java", "com.docker.Main.java"]
CMD ["java", "com.docker.Main.class"]
If i run the following command after the javac part, it lists Main.java and Main.class files.
RUN ls src/com/docker/
Well, maybe this picture will explain the parameters little bit more.

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With