say I have jcifs-1.3.14.jar in my lib folder, and I have a class that is importing from the library and uses the classes like:
import jcifs.smb.*;
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(domain,
user,
pass);
SmbFile file = new SmbFile(path, auth);
// do some operations with the file here
When using the library in this fashion is it considered to be: A) Static Linking OR B) Dynamic Linking OR C) something else?
Java is dynamically linked, has the slogan of "Code once, run everywhere", but it still requires JRE to run.
The main difference between static and dynamic linking is that static linking copies all library modules used in the program into the final executable file at the final step of the compilation while, in dynamic linking, the linking occurs at run time when both executable files and libraries are placed in the memory.
System provides two methods that allow your Java applications to load dynamic libraries: load() and loadLibrary() . Note: Applets are not allowed to load dynamic libraries. A call to either load() or loadLibrary() from within an applet will result in a SecurityException.
Statically-linked files are 'locked' to the executable at link time so they never change. A dynamically linked file referenced by an executable can change just by replacing the file on the disk. This allows updates to functionality without having to re-link the code; the loader re-links every time you run it.
If you are looking for information about applying various software licenses on Java programs, then searching Google for <license name> Java
usually results in a useful hit.
E.g for LGPL Java
, this is the first hit. In this particular case, the bottom line is:
Applications which link to LGPL libraries need not be released under the LGPL. Applications need only follow the requirements in section 6 of the LGPL: allow new versions of the library to be linked with the application; and allow reverse engineering to debug this.
I.e. as long as the library is provided in a separate JAR file that can be easily replaced, LGPL allows it.
PS: I Am Not A Lawyer! If in doubt, consult one. As a matter of fact, depending on where you live, it might make sense to consult one regardless if you are in doubt or not.
Static vs dynamic as in C++ doesn't exist in Java. All class get loaded into JVM as they are referenced, so you'd want to think that all imports (this includes reflections) in Java are dynamic.
And that .* is bad because of the naming and class discovery conflicts that it might incur, nothing to do with class referencing.
Well, you don't compile the code from library into your java classes. Your compiled classes refere the classes from other library by name. When need, the class is loaded by class loader. It's more similar to dynamic linking.
From licencing point of view - f.g. LGPL licence, it should be considered as dynamic linking. I've never heard of any law proceeding in that case (though I've searched for it), but it is high propable, I'm looking forward to it, because many developers are a bit anxious about it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With