Skip to content
Advertisement

If someone’s code says java version 1.8 in pom, does that mean that it is JDK 8?

I am looking at someone else’s code and the pom.xml says java version 1.8.

I need to know the version of the JDK. I know they can be the same, but some sites say they are different?

Sorry for the newb question and thanks

I tried googling this and couldn’t find an answer

EDIT: To be clear I know java 1.8 == Java 8. I am asking about the JDK. for example, if an exploit only works on JDK 9+ and my pom says java version 1.8, am I safe? My research says not necessarily but I’m not sure so asking here.

Advertisement

Answer

The version of the JDK installed on your computer may or may not be Java 1.8 (aka, Java 8). It means that the code wants to use Java 8 standards and produce output files that will work with Java 8. But you could easily use Java 17 to do this. Newer versions of the JDK can produce files that can be used on older versions of the JDK.

To find out what your JDK is, on a command line, run java -version. For me, I get:

openjdk version "17.0.2" 2022-01-18
OpenJDK Runtime Environment (build 17.0.2+8-Ubuntu-120.04)
OpenJDK 64-Bit Server VM (build 17.0.2+8-Ubuntu-120.04, mixed mode, sharing)

In your pom.xml you may have some lines that look like:

<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>

This tells Maven (and by extension the compiler) that your source code is targeted at Java 11 and the output from the compiler should be code that works with Java 11 and higher.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement