Docker issues (could not load or find main class)

Viewed 394

I am trying to perform a docker run however I keep getting the issue in the terminal which states Error: Could not find or load main class Main.

My Dockerfile is correctly named and the build did run and I can see the image when running docker run

The docker file is below:

FROM openjdk:8
COPY . /src/
WORKDIR /src/
RUN ["javac", "Main.java"]
ENTRYPOINT ["java", "Main"] 

Can someone please advise me what is the best approach to take at this point or what I should be looking out for?

Thanks

1 Answers

It sounds like your main class name is not "Main".

after compiling with "javac" java creates a class file named exactly as its main class name. I mean the class that contains the main method.

Related