Simple Java Application in Docker - Could not find or load Main class

Viewed 1745

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/
1 Answers

Well, maybe this picture will explain the parameters little bit more.

enter image description here

Related