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

Popular posts from this blog

C# random value from dictionary and tuple -

cgi - How do I interpret URLs without extension as files rather than missing directories in nginx? -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -