java - check whether a library has already been loaded with System.load(...) -
in java program, loaded library built native code by:
system.load(path_to_lib_file);
i wondering in java, how check whether specific library has been loaded before execute above code?
you have few options, load in singleton. can take advantage of single instance-ness of singleton ensure library loaded once. similarly, have boolean
flag , check (default false
) - if it's true library has been loaded, otherwise load library , set flag true
. there other options, none elegant (imo). example, place load
call in static initializer block in class, long don't serialize instances of class should ensure library loaded once.
Comments
Post a Comment