skip to Main Content

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


  1. Chosen as BEST ANSWER

    In my case i did the following:

    1. unpacked the jar file (it's just a zipped file, as most of programmers know)
    2. command
    javap -verbose AnyFile.class 
    
    1. the result was:
    Classfile /C:/blablalba/AnyFile$1.class
      Last modified 1980-01-31; size 1398 bytes
      MD5 checksum .........
      Compiled from "AnyFile.java"
    ...
      minor version: 0
      major version: 52
    

    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.


  2. As long as your compiler is Java compliant your are ok.

    Use target=1.8 and compiler will generate compatible bytecode.

    EDIT

    For gradle put

    java.targetCompatibility = 1.8
    

    into build.gradle.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search