What's the difference of compile time libraries and run time libraries in java?

后端 未结 4 1287
庸人自扰
庸人自扰 2021-01-17 23:40

And what are the pro\'s con\'s of using either?

I actually saw it in Netbeans under Project Properties > Libraries for Java Applications. We have two tabs, one for c

4条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-18 00:23

    Perhaps, this comes into play when you want to load a library dynamically, or check for an existence of the library and then execute the code.

    During compilation, compiler needs to know what the signatures of the methods, classes etc to know if you code is correct. Hence you add the compile time library.

    During runtime, JVM still needs the library to run that specific code. But you can put a logic to avoid that code by checking if the library exists, for example by doing Class.for() method. Some libraries might already exist in the system (qt.jar for example) or might not, and you can check and execute your code accordingly.

    Please correct me if I am wrong.

提交回复
热议问题