I downloaded and built the following jar:
https://github.com/pgjdbc/pgjdbc/tree/REL42.7.2
In particular, I ned the file postgresql.jar, and I must build by myself because I have to do a small change in its code (i cannot use the postgresql.jar as is provided from the official web page). I did succeed to make my change and to make it run on my application on a machine with Java 1.8.
But now, here is my doubt. In order to build the jar, I had to use Java 18, while Java 1.8 is installed on the computer where the application will run.
I cannot change the running Java on the machine where the jar will be loaded and used by my application. I cannot install Java 18 or a different Java than 1.8 on that computer.
Until now, the application seems working fine and connects with DB as expected. But I am afraid I will have some hidden problem. Why a jar that must be compiled with Java 18 is working with Java 1.8?
Maybe I should not worry, since no error is thrown, everything seems fine.
Anybody can give some info about?
Thank you.
UPDATE: the project is using kotlin (build.gradle.kts)
2
Answers
In my case i did the following:
So minor and major version are OK with Java 1.8, no matter which Java version was needed to build the jar. Seems the major version is more important, in this case, 52.
As long as your compiler is Java compliant your are ok.
Use
target=1.8
and compiler will generate compatible bytecode.EDIT
For
gradle
putinto
build.gradle
.