0

Im trying to dockerize my application and when I try to run the docker run command, I receive this error. I tried a lot of things where people say that java and javac are different versions, but they are the same; What is the problem in the situation and how can I resolve it? I will apply picture of the error, so you can see it. Also do I need to go back to previous version of java and how to do this? Thanks in advance! :)

Error

Slaw
  • 37,820
  • 8
  • 53
  • 80
Dimitar
  • 1
  • 1
  • If `com.redzone.RedZoneApplication` is your class, then `java` (in Docker) and `javac` (on your development machine) can't be the same version; you've compiled with a newer version (which means either upgrade Java used by Docker or downgrade Java used to develop). If it's a library class then you're using a library compiled with a newer version of Java (which means either upgrade Java in Docker or downgrade the dependency). – Slaw Jan 15 '21 at 12:55

1 Answers1

0

You have compiled your code with Java 10. Your docker has Java 8 runtime environment.

Ghokun
  • 3,345
  • 3
  • 26
  • 30
  • Can I run Java 10 environment or somehow I have to compile the code with java 8? – Dimitar Jan 15 '21 at 12:52
  • 1
    If you have control over docker image, you can change java environment. If you have control over source code you can compile with java 8. – Ghokun Jan 15 '21 at 12:56
  • How do I make my code to compile with java 8, I already tried to add: 1.8 1.8 in the properties of the pom file, but it is still not happening. – Dimitar Jan 15 '21 at 16:54
  • You need to install JDK 8 and point your maven to it. If you have multiple JDKs in your environment you can use maven toolchains or a dev env configuration tool like sdkman to change your JDK for a specific project. – Ghokun Jan 15 '21 at 19:44