created initialize function to load java library and removed same code from individual functions